Solved

Imported DLL crashed when run in 64-bit PC

Posted on 2013-11-20
8
366 Views
Last Modified: 2013-11-21
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
0
Comment
Question by:dominicwong
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
8 Comments
 
LVL 44

Accepted Solution

by:
AndyAinscow earned 500 total points
ID: 39665067
Your C code dll is probably 32 bit.
You can not (not directly) mix a 32 bit dll into a 64 bit application.  That is why the internet articles suggest compiling as x86 to keep it all as 32 bit.

I guess the dll is actually calling another dll or windows system API which isn't available in a 32 bit version on the 64 bit machine.  You could try using dependancy walker to look into the C dll that you have.

http://www.dependencywalker.com/
0
 

Author Comment

by:dominicwong
ID: 39665302
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.
0
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 39665419
>>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.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:dominicwong
ID: 39665438
thanks Andy.
with your other suggestion will I end up having two executables: one for 32bit and one for 64bit PCs?
0
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 39665449
>>one for 32bit and one for 64bit PCs?
Yes.  (ps.  Numbers of commercial products have the same, two builds 32 and 64 bit.)
0
 

Author Comment

by:dominicwong
ID: 39667510
I checked the "Configuration Manager". The "Active solution platform" is already "x86".
0
 

Author Closing Comment

by:dominicwong
ID: 39667604
Thanks Andy for your help.
I will submit a separate question for compiling app into 32bit.
0
 

Author Comment

by:dominicwong
ID: 39667633
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. :)
0

Featured Post

Want Experts Exchange at your fingertips?

With Experts Exchange’s latest app release, you can now experience our most recent features, updates, and the same community interface while on-the-go. Download our latest app release at the Android or Apple stores today!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

631 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question