November 30, 2006

Useful Assembly Methods

using System.Reflection;

//To retrieve the version number from the 
// assembly in your code, you use can do this:
string strVersion = 
Assembly.GetExecutingAssembly().GetName().Version.ToString(); //To retrieve the version number from the // assembly that is calling your assembly, // you can use this: string strVersion =
Assembly.GetCallingAssembly().GetName().Version.ToString(); // Retrieving the executing assembly's path as a Uri Uri uri = new Uri(System.IO.Path.GetDirectoryName( Assembly.GetExecutingAssembly().GetName().CodeBase)); // and as a string path string path = new Uri(System.IO.Path.GetDirectoryName( Assembly.GetExecutingAssembly().GetName().CodeBase)).LocalPath;

No comments: