C# Source Code: Tip: Getting the Current Assembly Name and Path
[
Home
|
Contents
|
Search
|
Reply
| Previous | Next ]
C# Source Code
Tip: Getting the Current Assembly Name and Path
By:
Andrew Baker
Email (spam proof):
Email the originator of this post
Date:
Tuesday, June 29, 2004
Hits:
1614
Category:
Attributes/Reflection/Debugging
Article:
In VB you could obtain the path of a DLL using App.Path. To obtain meta data about an assembly in .NET you need to use Reflection. Below is an example of how to return the current assembly name, the namespace and path: //Return the assembly name of the executing assembly Debug.WriteLine(System.Reflection.Assembly.GetExecutingAssembly().GetName().Name); //or //Return the assembly name of the specified type Debug.WriteLine(this.GetType().Assembly.GetName().Name); //Return the name space of a specified type Debug.WriteLine(this.GetType().Namespace); //Return the path of the executing assembly path Debug.WriteLine(System.Reflection.Assembly.GetExecutingAssembly().Location); //or //Return the path of this type Debug.WriteLine(this.GetType().Assembly.GetName().CodeBase); //Return the name of the application Debug.WriteLine(System.AppDomain.CurrentDomain.FriendlyName);
Terms and Conditions
Support this site
Download a trial version of the best FTP application on the internet