I can retrieve the path of a Windows form using the Application object.
However, if I write a class which will be compiled into a DLL, would it
be possible to retrieve the DLL path (without passing the Application
object to the class) ???
Ignacio Machin ( .NET/ C# MVP ) - 22 Dec 2005 14:56 GMT
H:
Assembly.GetExecutingAssembly().Location

Signature
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
>I can retrieve the path of a Windows form using the Application object.
> However, if I write a class which will be compiled into a DLL, would it
> be possible to retrieve the DLL path (without passing the Application
> object to the class) ???
Huy Hoang - 22 Dec 2005 15:02 GMT
Yeah, I saw there was a post about the same topic, a few posts earlier.
So I deleted my starting post, but somehow you managed to reply anyway.
Ignacio Machin ( .NET/ C# MVP ) - 22 Dec 2005 15:03 GMT
Hi,
Well I did the other answer too :)
> Yeah, I saw there was a post about the same topic, a few posts earlier.
> So I deleted my starting post, but somehow you managed to reply anyway.
Stoitcho Goutsev (100) [C# MVP] - 22 Dec 2005 15:08 GMT
Huy,
You can do this in a many different ways, but the goal is to get reference
to the assembly and check out its Location property.
For example:
1. From code in the DLL you can do
Assembly.GetExecutingAssembly().Location
2. If Foo is a class decalred in the DLL
typeof(Foo).Assembly.Location.
or
using Assembly's static method GetAssembly()
or
using object of a type decalred in the DLL
obj.GetType().Assembly.Location
3. Using the domain AppDomain.CurrentDomain.GetAssemblies() and then finding
out your assembly and check its Location property.
I believe there are more variations on this.

Signature
HTH
Stoitcho Goutsev (100) [C# MVP]
>I can retrieve the path of a Windows form using the Application object.
> However, if I write a class which will be compiled into a DLL, would it
> be possible to retrieve the DLL path (without passing the Application
> object to the class) ???