Solved

System.Windows.Forms.Application.StartupPath used for dll? Is there a better way?

Posted on 2009-04-07
9
716 Views
Last Modified: 2013-11-26
Hi,

I am investigating an ASP.NET app that someone else has written which uses a dll written in another project, of the same solution. However I notice that it uses the "System.Windows.Forms.Application.StartupPath" to define the path for this dll. Now I thought it would be better to just have this dll in the web site's "bin" folder. Am I missing something? If I am right then how would one force this?

Incidentally the "System.Windows.Forms.Application.StartupPath" results in "c:\windows\system32\inetsrv\myfile.dll" since I guess this is where the IIS executable lives.

Thanks in advance.

Ed
0
Comment
Question by:SamJolly
  • 6
  • 2
9 Comments
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 250 total points
ID: 24090837
Maybe there are multiple sites using that same dll? The bin folder does seem to be the logical place, though.
0
 

Author Comment

by:SamJolly
ID: 24090842
Hi,

Also had an alternate location on my dev server ie "'c:\windows\microsoft.net\framework\v2.0.50727\myfile.dll"

Thanks for any help,

Sam
0
 
LVL 14

Assisted Solution

by:jjardine
jjardine earned 250 total points
ID: 24090853
The issue is that the startup path is based on the parent process that calls the file.  Since it is in a web application, the startup path will come from inetsrv as the parent process.  This is similar to an add-in for office..  Startup path is the path to the exe that calls the dll, not where the dll is located.  It tends to work better for exe files that want to get the path they started from.  Because dll's are called from some other source I do not see this as reliable.  

Do you have access to the dll source to change this functionality?
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

Author Comment

by:SamJolly
ID: 24090881
hi kaufmed:,

Thanks for the reply... I do have multiple sites that use this dll, but I had assumed that they will all use their local "bin" one.

Still perplexed...

Sam
0
 

Author Comment

by:SamJolly
ID: 24090903
jjardine:,

Yes I do have access to the dll source.. So what should I do?

Sam
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 24090931
The benefit I could see to doing it this way is that you have one copy of the dll to update rather than adding the updated dll to each bin folder that needs it. It seems to me to be a matter of preference, though.
0
 

Author Comment

by:SamJolly
ID: 24090975
Kaufmed, I see where you are coming from. The only reason I have multiple sites is that they are all multiple versions of the same thing so I would be happier keeping all the web app code together in addition to the fact that I get into all sorts of deployment issues if I do not have admin rights, hence the preference for using the "bin".

The offending DLL has the offending "ReferencedAssemblies.Add(System.Windows.Forms.Application.StartupPath + "zmyfile.dll") code... I know not quite right... but you get the idea.

Sam
0
 

Author Comment

by:SamJolly
ID: 24193087
Hi All,

I have now sorted this using an alternative approach.

Thanks anyway...

Sam
0
 

Author Closing Comment

by:SamJolly
ID: 31567691
thanks
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question