Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# Solution, can all projects target AnyCPU except one which has to be x86?

We have a large solution comprising of many different libraries. We have just migrated to development on a 64bit system and this has us thinking about what platform target we should specify for each individual project in the solution.

At the current time, we only have one library project which references a 32 bit DLL file. We reference an Interop of this DLL file however we receive an error when targeting x86 as the platform for this project whilst leaving the remaining projects in the solution as "Any CPU".

My question is, can we target Any CPU on all of our projects except for the one which references the 32 bit interop? Or should be just build everything for x86 as this seems to work without any error.

like image 957
Horges Avatar asked Oct 14 '22 21:10

Horges


2 Answers

Yes.

All DLLs but one can be AnyCPU.

Just be sure to make the process x86, and all the DLLs will load as 32 bits.

What is the error you are getting? Adding the error message would likely result in more helpful answers.

like image 97
codekaizen Avatar answered Oct 27 '22 10:10

codekaizen


I think if all of your dll's are anyCpu, your .exe can be either x64 or x86. But, if your exe is either x64 or x86 your .dlls cannot be the other. Additionally, if your .exe is AnyCPU, I believe it will load in whatever mode is native to the machine. Which means that your dll's had either be anyCpu or the native mode for your system.

like image 34
MarkPflug Avatar answered Oct 27 '22 11:10

MarkPflug