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

2

6

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.

Yarborough answered 4/11, 2010 at 1:55 Comment(0)
D
4

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.

Darkroom answered 4/11, 2010 at 2:21 Comment(3)
we are developing on a 64 bit machine. when we target "Any CPU" for all projects except for the library requiring reference the 32 bit DLL, it doesn work. We receive an error message "Retrieving the COM class factory for component with CLSID {numbers} failed.Yarborough
Ah, yes, then it won't work. It should work if you change only the EXE project to x86.Darkroom
Yes, that works. We set ONLY the main application to X86 and the rest can remain as AnyCPU. When (and if we can) we obtain a new DLL that supports 64 bit all we'll need to do is change the target platform for the main application. Thanks codekaizenYarborough
F
2

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.

Fayola answered 4/11, 2010 at 2:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.