Home All Groups Group Topic Archive Search About

get the project path

Author
23 Nov 2006 12:30 PM
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

Author
27 Nov 2006 7:10 AM
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 :)

--
Dave Sexton

Show quote
"Irfan" <ir***@asc-ltd.co.uk> wrote in message
news:eRocxsvDHHA.3600@TK2MSFTNGP06.phx.gbl...
> 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
>
>

AddThis Social Bookmark Button