Last week I stumbled upon a problem and I'm not sure how to solve it. I already spent a whole day to try to solve it alone.
I have an unmanaged DLL that worked fine in my C# code on a Windows XP (32 bit) System. When I try to run this C# code on a newer System (for example Windows 7 (64 bit) it doesn't work anymore.
This is the code
[DllImport("MyTest.dll")]
[return: MarshalAs(UnmanagedType.LPStr)]
public static extern String DoSomething();
As I said this works fine on my Windows XP System but doesn't work on my Windows 7 System. When I try to run this code on my Windows 7 System I get the following Exception (translated into English)
The DLL "MyTest.dll": Recurrence too deep, Stackoverflow. (Exception from HRESULT: 0x800703E9) can not be loaded.
I'm guessing the problem is because of this:
Load 32bit DLL library in 64bit application
How to call win32 dll in windows 7
I'm just not sure about it because when I search for my exception in combination with DLLImport I can't find anything.
If this is really the problem what would be the best solution?