Solved

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

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

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
 

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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:SamJolly
ID: 24090903
jjardine:,

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

Sam
0
 
LVL 74

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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

758 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now