简体   繁体   中英

Debugging Unable to load DLL 'MyDll.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)

I am hitting the exception:

Unable to load DLL 'MyDll.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)

As the answer to Unable to load DLL (Module could not be found HRESULT: 0x8007007E) suggests, we want to keep the unmanaged dll in the current directory, together with all the managed dlls (and it is there). How can I, for debugging purposes, print the current directory that will be used to load the dll? Is it Directory.GetCurrentDirectory() ?

You can use Environment.CurrentDirectory to get the current working directory for your application. This should give you want you want.

Assembly.GetExecutingAssembly().Location will return the directory that contains the executable or DLL that's currently executing.

CurrentDirectory can be changed by FileDialogs and other classes. So, it may not be the same as the directory that contains the entry point for the application.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM