[英]Importing x86_64 DLL in project with x86 environment through P/Invoke
My current target framework is .NET Framework v4.0.我目前的目标框架是 .NET Framework v4.0。
I'm having issues importing the DLL as I get the "BadImageFormatException" similar to this post BadImageFormatException when loading 32 bit DLL, target is x86我在导入 DLL 时遇到问题,因为我在加载 32 位 DLL 时收到类似于此帖子 BadImageFormatException 的“BadImageFormatException”,目标是 Z8A9DA7865483C5FD359F3ACEF178D2D6
From there I realised that the DLL (retrieved from NuGet) can only be built in x64, but my solution can only be x86 as that is what the team has decided on.从那里我意识到 DLL(从 NuGet 检索)只能在 x64 中构建,但我的解决方案只能是 x86,因为这是团队决定的。 So I can't change the configuration to x64.
所以我无法将配置更改为 x64。
I'm currently using P/Invoke to import it (DllImport).我目前正在使用 P/Invoke 来导入它(DllImport)。 My machine is x64.
我的机器是x64。 For context, this DLL is built with managed native c++ code and I am trying to convert it to c#.
对于上下文,此 DLL 是使用托管本机 c++ 代码构建的,我正在尝试将其转换为 c#。 I cannot touch the dll as it is not my library, but my project is in c#.
我无法触摸 dll,因为它不是我的库,但我的项目在 c# 中。
Since I am not allowed to change my project settings, and the DLL can only be built in and run in x64, is there any other way to solve this issue?由于我不允许更改我的项目设置,并且 DLL 只能在 x64 中内置和运行,有没有其他方法可以解决这个问题?
You can not load a 64-bit dll in a 32-bit process.您不能在 32 位进程中加载 64 位 dll。 Your options are:
您的选择是:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.