Link to home
Start Free TrialLog in
Avatar of chcw
chcwFlag for Hong Kong

asked on

C# calling unmanaged DLL failed under Windows 7, but successfully under XP

I have an unmanaged 32bit DLL, which uses callback function.

When using unmanaged codes, such as Visual C++, Delphi, Visual Basic, all of them can call the DLL successfully under both Windows XP(SP3) and Windows 7(32bit and 64bit). I have made many tests without any problems.

When using C# to call the DLL under Windows XP(SP3), everything is still OK.

However, when using C# to call the DLL under Windows 7(32bit), I will always get the error message as follows:

 User generated image
After some time, the messagebox will ask me whether to debug or not, if I choose to debug, then Visual Studio 2008 will be loaded, as follows:

 User generated image
Then if I select the "Break" button, I will get into disassembled codes, as follows:

 User generated image
The C# program is built for .NET framework 3.5, and I have confirmed that .NET framework 3.5 has been installed on the system.

Can anyone tell me what is the problem? Thanks
Avatar of Didier Vx
Didier Vx
Flag of France image

Have you tried to change the .net framework version in your c# project ?
ASKER CERTIFIED SOLUTION
Avatar of AndyAinscow
AndyAinscow
Flag of Switzerland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of chcw

ASKER

Thanks to all of you. I have solved the problem by myself. Acutally the problem is not caused by the DLL or the C# program. Instead, as I use a third-party tool to protect the DLL, which cause the problem. Now I have upgraded the third-party tool to a new version to solve the problem.