Link to home
Start Free TrialLog in
Avatar of dominicwong
dominicwong

asked on

Imported DLL crashed when run in 64-bit PC

Hi experts
My c# project imports a DLL generated by C code, and my program calls one method in the imported DLL. Everything works fine in 32-bit PCs (XP and 7).

But the trouble is it crashes in 64-bit (Windows 7) PC.

Some Internet articles suggested to change the Build environment to "x86".
I did that to the StartUp project of my program (which consists of several projects). I right-clicked on the StartUp project, selected Properties, and I changed "Platform target" to "x86". I also did that at the top of the menu bar. (Please refer to the screenshot).

But the problem is still the same. Could someone tell me how I might fix this crash issue?
Thanks.
64bit.JPG
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
Avatar of dominicwong
dominicwong

ASKER

Hi Andy
The imported C code dll is 32 bit. It was written by someone else in the company. Therefore I have the source code. The C code doesn't call any other dll or windows system API.

I don't understand why the executable still doesn't run in 64 bit PC despite already compile in x86 (as per the screen shot attached to the question). Do you think I'd missed out anything in my settings?

Thanks.
>>Do you think I'd missed out anything in my settings?
Have a look at the menu point build : configuration manager.  In the picture at the top you have Active Any CPU, make a new configuration specifically for x86.  Maybe that will make a difference.

As you have the source code it might be simplest to compile a 64 bit version for the 64 bit operating systems.
thanks Andy.
with your other suggestion will I end up having two executables: one for 32bit and one for 64bit PCs?
>>one for 32bit and one for 64bit PCs?
Yes.  (ps.  Numbers of commercial products have the same, two builds 32 and 64 bit.)
I checked the "Configuration Manager". The "Active solution platform" is already "x86".
Thanks Andy for your help.
I will submit a separate question for compiling app into 32bit.
The problem is resolved. In my case, the trick is to change only the 'Platform Target' but leave the Configuration Manager unchanged.
Thanks for your help again. :)