Click here to Skip to main content
Rate this: bad
good
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 5:20am
sarngon110
Comments
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.
--SA
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.
--SA

1 solution

Rate this: bad
good
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.
 
[EDIT]
 
Thanks to Matt T Heffron for the correction.
 
—SA
  Permalink  
v3
Comments
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.
--SA
Sergey Alexandrovich Kryukov at 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)

  Print Answers RSS
0 OriginalGriff 7,130
1 DamithSL 5,089
2 Maciej Los 4,866
3 Sergey Alexandrovich Kryukov 4,647
4 Kornfeld Eliyahu Peter 4,409


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

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100