I have a problem when compiling a managed DLL project. The solution consists of two projects, the first is a .NET DLL written in C# and the other is Managed C++ DLL that directly references the C# project.
Both projects/DLLs are strongly named with an snk file on disk. The C# dll has a target framework of "AnyCPU"
while the Manage C++ project is compiled twice, one for an x86 target and the other for an x64.
My problem is that when I compile the Managed C++ project to target the x86 platform, the result DLL has a PublicKeyToken = null
as reported by ILSpy
. When compiling to target an x64 platform, the DLL has the correct PublicKeyToken. I have checked my project properties, the snk file is referenced correctly for both platform targets under Configuration Properties -> Linker->Advanced->Key File
with no delay signing; the Target Machine
option is also set correctly based on the desired compilation target.
Here is the information shown by ILSpy when I load my DLL.
For the x64 dll:
// MyDll.x64, Version=1.1.1000.1, Culture=neutral, PublicKeyToken=XXXXXXXXX
// Architecture: x64
// This assembly contains unmanaged code.
// Runtime: .NET 2.0
For the x86 dll:
// MyDll.x86, Version=1.1.1000.1, Culture=neutral, PublicKeyToken=null
// Architecture: AnyCPU (64-bit preferred)
// This assembly contains unmanaged code.
// Runtime: .NET 2.0
What concerns me is the Architecture description for the x86 assembly: AnyCPU (64-bit preferred)
I am not sure why its using the AnyCPU configuration and what the 64-bit preferred annotation means exactly?
I also like to mention that my project is built against .NET Framwork 2.0 for the C# project while the Managed c++ project is built against the v90 Platform Toolset. I am using Visual Studio 2010 running on a Windows 7 64-bit machine.
Can someone tell me why this is happening and how can I solve this issue?