[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

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

Posted on 2009-04-07
9
Medium Priority
?
771 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 1000 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 1000 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

649 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