如何从 Windows Server 2003 64 位版本上运行的 C# 调用 32 位 C DLL?
我知道我无法使用默认的“平台目标:任何 CPU”构建设置来编译我的 C# 代码并调用 32 位 C DLL。但是,如果我将此设置更改为“平台目标:x86”,C# 代码应该在 32 位上下文下运行并在该 32 位上下文下调用 C DLL,对吧?虽然看起来并没有什么作用。
我是否必须使用一些特殊的注册表或其他东西来注册 32 位 C DLL?
我使用的是 Windows Server 2003 64 位。
错误是:
Runtime Error!
[Path to dll]
R6034
An application has made an attempt to load the C runtime library incorrectly.
I know I can’t compile my C# code using the default ”Platform Target : Any CPU” build setting and call a 32 bit C DLL. But if I change this setting to ”Platform Target : x86” the C# code should run under a 32-bit context and call the C DLL under that 32 bit context right? Although it doesn’t seem to work.
Do I have to register the 32-bit C DLL with some special registry or something?
I am using Windows Server 2003 64 bit.
The error is:
Runtime Error!
[Path to dll]
R6034
An application has made an attempt to load the C runtime library incorrectly.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你是对的。如果您使用设置为 x86 的平台进行构建,则您的 32 位 DLL 应该可以正常工作。
如果不是,请检查以下事项:
编辑:看到您的评论后,您的问题是由于 DLL 没有正确的清单。如果您在 DLL 中嵌入清单,它应该能够正确解析正确的 C 运行时并加载它(前提是部署计算机上安装了正确的运行时。)
You are correct. If you're building with the platform set to x86, your 32bit DLL should work fine.
If it's not, here are some things to check:
Edit: After seeing your comment, your issue is due to the DLL not having a proper manifest. If you embed a manifest in the DLL, it should be able to properly resolve the correct C runtime, and load it (provided the correct runtime is installed on the deployment machine.)