I have a DLL written in C++ that needs to be used by an application in C#. It works great under Vista x86, but under x64 it fails to load. So I build an x64 version of the DLL and I detect whether the OS is x86 or x64 and use the appropriate interop call to the appropriate DLL. This works fine under Vista x86, but under Vista x64 I get a "side-by-side" error when it tries to load the DLL. Why exactly is it failing to load it, and what can be done to correct this? (Please let me know if you need more information, I'm not sure what information is relevant in trouble-shooting this issue.)
One first idea: Could you try setting the "Platform Target" setting in the C# part of the project to "x86", to see if it will run in 32-bit compatibility mode on the Vista 64 machine?
More information about the SxS error would be useful - it might be related to some specific (32-bit?) versions of the runtime libraries that are not installed?
Hi, some further information to the answer of MadKeithV:
In Windows x64 a process may be started as 32bit or 64bit process. A 64bit process can only load 64bit dlls and a 32bit process only 32bit dlls.
If your platform target (e.g. specified in the project properties) of your .Net application is set to "Any CPU", the intermediate code will be compiled to 32bit or 64bit code depending on the target platform, i.e. on a x64 system 64bit code will be generated.
Therefore the code can no longer load a 32bit dll.
If your code loads unmanaged assemblies you should always specify the target platform explicitly.
Best regards, divo
The side by side error is more then likely caused by you c++ dll manifest file settings either they are not getting embedded or you have chosen to not embed the manifest and is using the 32bit versions manifest.
The simple solution is to mark your c# application as for the x86 cup and run with the 32bit dll.
If nothing else works.. you can give Process Monitor a try. It shows you which file (dependency) was not found.. this may give you a lead to proceed.
The redist for VC90 for x64 will need to be installed on the client machine. As far as the manifest goes, I think you can alter it to remove the processorArchitecture tag. Either that or have it say "any".