Click here to Skip to main content
15,886,721 members
Please Sign up or sign in to vote.
1.11/5 (2 votes)
See more:
Hi guys,
I have a 64 bit processor machine and I could import 32 bit dll but I wouldnt do the sama at 64-bit dll? Why ?
Posted
Updated 9-Dec-18 20:38pm
Comments
Albert Holguin 10-Dec-12 10:39am    
Your question isn't making sense, can you elaborate what you're talking about?
Sergey Alexandrovich Kryukov 10-Dec-12 16:39pm    
Logically, if something worked out for 64-bit DLL (what instruction-set architecture, by the way? there are at least two of 64-bit), it means that the .NET assembly was also 64-bit, otherwise it would not work. The target CPU of this assembly should be changed. -- please see my answer and my comment below.
--SA
ZurdoDev 10-Dec-12 10:50am    
Is there an error?
Sergey Alexandrovich Kryukov 10-Dec-12 16:40pm    
Unfortunately, the mistakes like OP's produce not very comprehensible messages. I know what it is -- please see my comment above and my answer.
--SA

1 solution

The target CPU for C# .NET P/Invoke should match the DLL target CPU.

If you want to import 64-bit DLL, you should set one of 64-bit targets for the target CPU in your .NET project options. CPU instruction-set architectures never ever can be mixed in the same process.

[EDIT]

Thanks to Matt T Heffron for the correction.

—SA
 
Share this answer
 
v3
Comments
Matt T Heffron 10-Dec-12 19:12pm    
OP said that 32 bit import worked, but 64 bit didn't.
I think the target CPU in the project options need to be set to "x64" (or "Itanium" as appropriate).
Sergey Alexandrovich Kryukov 10-Dec-12 23:23pm    
Thank you for the correction. Whatever it is, the target instruction-set architectures should match.
--SA
Sergey Alexandrovich Kryukov 10-Dec-12 23:26pm    
Text modified, your correction credited. Thank you again.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900