Location of Assemblies invoked via Reflection
If you are loading assemblies using Reflection, sometimes you might have to know the location of assembly from your main application. You cant use the GetCurrentDirectory method, since it always returns the application folder, even if the assembly is from some other folder.
Here is the way to establish the same. Provide the following method in your assembly and invoke the same from your parent application.
public string GetAssemblyDir() {
string sLoc = System.Reflection.Assembly.GetExecutingAssembly().Location;
System.IO.FileInfo fileInfo = new System.IO.FileInfo(sLoc);
return fileInfo.DirectoryName;
}
Posted October 14, 2004
Comments(0)












