Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Determine where .dll is

Status
Not open for further replies.

DevonTaig

Programmer
May 2, 2001
73
US
I have created a C# .dll that is hosted by a running .exe. I need to find the path to where the .dll is installed because I have a directory that is placed relative to the .dll that I need to access during the execution of the code. I have tried the following, but the refer to the running .exe...not the .dll.

AppDomain.CurrentDomain.RelativeSearchPath
AppDomain.CurrentDomain.BaseDirectory
System.IO.Directory.GetCurrentDirectory

Any ideas?
 

If the module is part of your AppDomain or your assembly then :

Assembly mainAssembly = Assembly.GetExecutingAssembly();
Module Mod = mainAssembly.GetModule("mydll.dll");
string modulePath = Mod.FullyQualifiedName ;
If the Dll is accessed using DllImport attribute then you should use
GetModuleFileName( HMODULE hModule, LPTSTR lpPathFilename, DWORD nSizeBuffer);

-obislavu-
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top