get the project path

I

Irfan

hi,

I need to know the locaton of a project that i am referencing in my project.

So in the project that i want to reference
I created a public method in a class that returns Application.StartUpPath .

However, when i access this method from my project it return the StartUpPath
of MY project instead of the project that i have referenced.

Can someone give me some idea how to get the path of the project that i am
referncing.

Regards,
irfan
 
D

Dave Sexton

Hi Irfan,

That is the expected behavior of Application.StartupPath, which returns the
path for the .exe that started the application.

Instead, try returning,
System.Reflection.Assembly.GetExecutingAssembly().Location from the method
in your referenced assembly.

Realize, however, that this is not the path of the project reference, it's
the path of the file that contains the assembly manifest. Once the code is
compiled, there is no way to dynamically access the path to the actual VS
"project" that created the assembly. If you need that information at
runtime then you'll have to hard-code it, but I'm almost positive that's not
what you mean :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top