Get DLL path at runtime

You can use the GetModuleHandleEx function and get the handle to a static function in your DLL. You’ll find more information here. After that you can use GetModuleFileName to get the path from the handle you just obtained. More information on that call is here. A complete example: char path[MAX_PATH]; HMODULE hm = NULL; if … Read more

Is it OK to use DYLD_LIBRARY_PATH on Mac OS X? And, what’s the dynamic library search algorithm with it?

As you’ve noted, DYLD_LIBRARY_PATH behaves like LD_LIBRARY_PATH on other *nix. However, there is another environment variable you should look at called DYLD_FALLBACK_LIBRARY_PATH. In general, these are (both on osx and linux) suggested only for development use as they can cause symbol lookup errors when you override with a library that does not have the same … Read more

How do I build an import library (.lib) AND a DLL in Visual C++?

Does your DLL project have any actual exports? If there are no exports, the linker will not generate an import library .lib file. In the non-Express version of VS, the import libray name is specfied in the project settings here: Configuration Properties/Linker/Advanced/Import Library I assume it’s the same in Express (if it even provides the … Read more

Can you remove an Add-ed Type in PowerShell again?

Like the others say, this is a .NET behavior. Assemblies loaded into an AppDomain cannot be unloaded. Only the AppDomain can be unloaded, and powershell uses a single appdomain. I blogged a bit about this some years ago: https://web.archive.org/web/20170707034334/http://www.nivot.org/blog/post/2007/12/07/WhyAppDomainsAreNotAMagicBullet When I test like this, I usually keep a shell open and use a nested shell … Read more

How do I find out which dlls an executable will load?

dumpbin is a tool that comes with VC++. To see what DLLs a program will import: Open Visual Studio Menu Item Tools | Visual Studio Command prompt cd to folder containing executable dumpbin /dependents whatever.exe Dump of file whatever.exe File Type: EXECUTABLE IMAGE Image has the following dependencies: AIOUSB.DLL sqlite3.dll wxmsw293u_core_vc_custom.dll wxbase293u_vc_custom.dll KERNEL32.dll ole32.dll OLEAUT32.dll … Read more

Compilation Error: The type ‘ASP.global_asax’ exists in both DLLs

In my case the problem occurred in a virtual application’s bin folder. Looking into this bin-folder you will probably see two files (an information I found here): App_global.asax.dll App_global.asax.compiled Removing these resolves the error. The App_global.asax.dll is generated at runtime too which causes the problem. I am however still investigating how these files got there, … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)