Unable to load DLL The specified module could not

2019-08-28 17:38发布

问题:

When using [DllImport("my.cool.library")] with .NET you get an error similar to the following:

"Unable to load DLL... The specified module could not be found..."

...even though all the required DLLs are in place and clearly accessible!?

回答1:

Turns out DLLImport only assumes the ".dll" extension if you do not have periods in the name. If DLLImport("my.cool.library.dll") was used, it would work, otherwise the DLL will have to be renamed to "my_cool_library.dll", and then DLLImport("my_cool_library") will work. ;)