Is there any solution to the problem of d开发者_如何学运维eploying a single application compiled with target platform as AnyCPU that rely on a .NET wrapper of legacy C++ code to both x86 and x64 operating systems? Do you need in all cases to provide two application executables one compiled with target platform as x86 and the other with x64 respectivaly referencing the x86 wrapper and the x64 wrapper?
Thanks!
I use a launcher app which will test the OS and move around the DLLs so that at runtime the proper DLLs are used (use x86 dlls on 32-bit OS, etc.). The logic in the launcher is quite simple. Something like:
If IntPtr.Size = 8 Then
'-- Copy x64 DLLs into position
Else
'-- Copy x86 DLLs into position
End If
Of course, when copying, you need to copy back so you can always switch between x64 and x86 (in the case of a portable application). However, if you're installing a non-portable application then there is no need for the launcher as this OS check can all be done inside the installer (so only the proper DLLs get installed). Visual Studio install projects don't allow this (because you can't mix x64 and x86 components in one installer) but InstallShield does allow it (that's what I use).
You will need to edit your project file to use a non-specific version of the DLLs in question (otherwise this moving around and conditional install logic will not do what you want it to).
精彩评论