Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / December 2005

Tip: Looking for answers? Try searching our database.

Retrieving path of a DLL

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Huy Hoang - 22 Dec 2005 14:48 GMT
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) ???

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.