ExecutionEngineException thrown when loading native dll
I have a 32-bit .net application that uses a native 32-bit DLL via DllImport(). The native DLL is our internal file analysis library, and I need to use it as porting it to C# would be a problem if people update it (other software uses it).
The problem is that when I try to execute any method in the native DLL I get a System.ExecutionEngineException thrown. In fact, I've reduced the managed application to a simple tester that just calls a native method, but it still fails.
I am on 64-bit Windows 7, but that should not matter as I'm compiling everything as 32-bit binaries.
What is also interesting, when I look at the native DLL in the Dependency Walker, it shows that it can't find msvcr90.dll - but when I open any other of our native DLLs in the Dependency Walker, it can find their referenced msvcr90.dll just fin开发者_StackOverflow社区e. Can there by some wrongness in the compilation of native DLL that messes up its DLL references?
OK - the problem was a little bit misty. Apparently a colleague modified the native DLL's method to contain one parameter with default value (that C++ handles just fine), but, as we know, C# 3.5 does not. After supplying a value for that parameter, everything worked fine!
精彩评论