Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
See more: C++ C# DLL
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 10-Dec-12 4:20am
Albert Holguin at 10-Dec-12 10:39am
Your question isn't making sense, can you elaborate what you're talking about?
Sergey Alexandrovich Kryukov at 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.
ryanb31 at 10-Dec-12 10:50am
Is there an error?
Sergey Alexandrovich Kryukov at 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.

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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.
Thanks to Matt T Heffron for the correction.
Matt T Heffron at 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 at 10-Dec-12 23:23pm
Thank you for the correction. Whatever it is, the target instruction-set architectures should match.
Sergey Alexandrovich Kryukov at 10-Dec-12 23:26pm
Text modified, your correction credited. Thank you again.

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

Advertise | Privacy | Mobile
Web02 | 2.8.140709.1 | Last Updated 10 Dec 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid