简体   繁体   English

32位dll在64位服务器C#上不起作用

[英]32bit dll not work on 64bit Server C#

I have compiled ac natives 32bit DLL with Dev-C++, create the reference on my asp.net project, write a dllImport directives and use my new DLL. 我已经用Dev-C ++编译了ac natives 32位DLL,在我的asp.net项目上创建了引用,编写了dllImport指令并使用了我的新DLL。 When launch my DEBUG session all work very well but when deploy my project on Web Server the runtime not load my DLL. 启动我的DEBUG会话时,所有工作都很好,但是在Web Server上部署我的项目时,运行时不会加载我的DLL。

My IIS 7.0 w3wp.exe runs as a 64 bit process (to check if your process running as a 32 bit process under WOW64, open the task manager's Process tab and see if the process name contains "*32"). 我的IIS 7.0 w3wp.exe作为64位进程运行(要检查您的进程是否在WOW64下作为32位进程运行,请打开任务管理器的“进程”选项卡,并查看进程名称是否包含“ * 32”)。

I believe that a 64 bit process can only load 64 bit native DLLs (and managed DLLs built for "Any CPU" or "X64"). 我相信64位进程只能加载64位本机DLL(以及为“任何CPU”或“ X64”构建的托管DLL)。 Perhaps your debug session is a 32 bit session? 也许您的调试会话是32位会话? If this is the cause, take a look at Using a 32bit or 64bit dll in C# DllImport . 如果这是原因,请查看在C#DllImport使用32位或64位dll

For those of you who still cannot find a proper way to use a 32-bit DLL under a 64-bit IIS Application Pool, either by tweaking the registry, or by trying how to deal with the "COM+ Components Services", I have found a perfectly working solution : "Encapsulating" the 32-bit component into a new COM object as described on this page did the job perfectly, and I think that a lot of you will be interested to solve the problem this way ;) http://www.chestysoft.com/component-services.asp 对于仍然无法找到适当方法在64位IIS应用程序池下使用32位DLL的那些人,可以通过调整注册表或尝试使用“ COM +组件服务”来解决,完美的解决方案:将此页面中所述的32位组件“封装”到一个新的COM对象中,可以很好地完成工作,我想很多人都希望以此方式解决问题;) http:// /www.chestysoft.com/component-services.asp

In my case, that allowed me to use the "XStandard.Zip" free Component from XStandard, which is sadly only available as a 32-bit ASP component, and that have an "InProcServer32" Key in the registry apparently preventing it to work by tweaking the registry, as described here : https://techtalk.gfi.com/32bit-object-64bit-environment/ 就我而言,这使我可以使用XStandard的免费组件“ XStandard.Zip”,该组件只能作为32位ASP组件使用,并且在注册表中具有“ InProcServer32”键,显然阻止了它的工作。调整注册表,如下所述: https : //techtalk.gfi.com/32bit-object-64bit-environment/

In this post, a lot of comments reported that "InProcServer32-IDs are not reflected because Microsoft assumes that these are only InProc-Calls and not Out-Of-Proc-Calls ". 在这篇文章中,许多评论报告“ 由于Microsoft假定 InProcServer32-ID 仅是InProc-Calls而不是Out-Of-Proc-Calls,因此未反映出来 ”。 And that was my case too, leading me to the situation where the registry tweaking solution described in the previous post was not working in my case, as other users. 这也是我的情况,导致我遇到以下情况:与其他用户一样,上一篇文章中描述的注册表调整解决方案在我的情况下不起作用。

Hoping having saved some days... or nights ! 希望节省一些...或夜晚!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM