Can't load C ++ DLL into C # application on Vista x64
I have a DLL written in C ++ that needs to be used by a C # application. It works fine under Vista x86, but it won't boot under x64. So I create an x64 version of the DLL and I determine if the OS is x86 or x64 and use the appropriate interop call for the corresponding DLL. This works fine under Vista x86, but under Vista x64 I get a side-by-side error when trying to load a DLL. Why doesn't he load it, and what can be done to fix it? (Please let me know if you need more information, I don't know what information is relevant to troubleshooting this issue.)
source to share
One of the first ideas. Could you try to set the "Platform Target" option in the C # part of the project to "x86" to see if it will run in 32-bit compatibility mode on a Vista 64 machine?
More information on the SxS error would be helpful - perhaps this is due to some specific (32-bit?) Versions of the runtime libraries not installed?
source to share
some additional information to MadKeithV's answer:
On Windows x64, a process can be run as a 32-bit or 64-bit process. A 64-bit process can only load 64-bit DLL files, while a 32-bit process can only load 32-bit DLL files.
If your target platform (for example, specified in the project properties) of your .Net application is set to "Any processor", the intermediate code will be compiled to 32-bit or 64-bit code depending on the target platform, that is, on an x64 system. 64-bit code created.
Therefore, the code can no longer load the 32-bit DLL.
If your code is loading unmanaged assemblies, you must always explicitly specify the target framework.
source to share
If nothing else works, you can give Process Monitor a try. It shows which file (dependency) was not found. This may lead to a continuation.
source to share