Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

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

Posted on 2009-04-07
9
725 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

Suggested Solutions

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display

829 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