For further problems call
Marshal.GetLastWin32Error();
which should give you an error code.
Is it possible that you have deployed a debug version of your native dll that also requires a debug version of MSVCR90 D .DLL? You had to distribute the release version because a different set of DLLs must be installed on the target system for the debug version.
It clearly works on your development machine because all debug versions of the required libraries come with Visual Studio.
Here's how you get the message belonging to the error code:
[DllImport("kernel32.dll")] private static extern int FormatMessage(int dwFlags, IntPtr lpSource, int dwMessageId, int dwLanguageId, out string lpBuffer, int nSize, IntPtr pArguments); public static string GetErrorMessage(int errorCode) { const int FORMAT_MESSAGE_ALLOCATE_BUFFER = 0x00000100; const int FORMAT_MESSAGE_IGNORE_INSERTS = 0x00000200; const int FORMAT_MESSAGE_FROM_SYSTEM = 0x00001000; string lpMsgBuf; int dwFlags = FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS; int retVal = FormatMessage(dwFlags, IntPtr.Zero, errorCode, 0, out lpMsgBuf, 0, IntPtr.Zero); if (0 == retVal) { return null; } return lpMsgBuf; }
Dirk vollmar
source share