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.)

+1


source to share


5 answers


Repeater for VC90 for x64 must be installed on the client machine. As for the manifest, I think you can modify it to remove the architecture tag of the architecture. Either that or say "anyone."



+2


source


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?

+3


source


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.

+2


source


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.

+1


source


The side error is more likely because you are setting the C ++ dll manifest file options, or they are not injected, or you have chosen not to embed the manifest and use the 32-bit manifest.

An easy solution is to mark your C # application as x86 cup and run with a 32 bit dll.

0


source







All Articles