Solved

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

Posted on 2009-04-07
9
734 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
[X]
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
  • 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
Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

 

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

Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

Question has a verified solution.

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

This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

733 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