[英]Why am I able to call a 32 bit COM library from an AnyCPU .NET web application running in IIS7 in 64 bit mode?
Without using a COM+ proxy service, I'm quite happily able to use classes from a 32 bit COM interop library from a .NET application compiled with target AnyCPU, running in a 64 bit w3wp process.在不使用 COM+ 代理服务的情况下,我很高兴能够使用来自使用目标 AnyCPU 编译的 .NET 应用程序的 32 位 COM 互操作库中的类,该应用程序在 64 位 w3wp 进程中运行。
I'm successfully instantiating classes from a 32 bit COM interop library in a 64 bit .NET process.我在 64 位 .NET 进程中成功地从 32 位 COM 互操作库实例化类。
w3wp is running in 64 bit mode, and the IIS configuration is set to not allow 32 bit applications. w3wp 在 64 位模式下运行,并且 IIS 配置设置为不允许 32 位应用程序。 Ontop of that is the fact that there's a specifically x64 compiled and registered .NET assembly down the line.除此之外,还有一个专门 x64 编译和注册的 .NET 程序集。
I'm just wondering, how is this at all possible?我只是想知道,这怎么可能?
Of interest is that this works just beautifully if the code is compiled with Visual Studio 2008, targeting the 3.5 framework.有趣的是,如果代码是使用 Visual Studio 2008 编译的,目标是 3.5 框架,这将非常有效。 If the same code is compiled with Visual Studio 2010, targeting the 3.5 framework, the application fails spectacularly when it tries to load the 32 bit COM interop library.如果使用针对 3.5 框架的 Visual Studio 2010 编译相同的代码,则应用程序在尝试加载 32 位 COM 互操作库时会严重失败。 As it should.正如它应该。
It will be running in 32-bit mode if it is running at all, you cannot have 32bit stuff in a 64bit process and vice versa.如果它正在运行,它将以 32 位模式运行,你不能在 64 位进程中拥有 32 位的东西,反之亦然。 A process is entirely one or the other.一个过程完全是一个或另一个。
That is not the same as running a 32bit process on a 64bit host, obviously, that works.这与在 64 位主机上运行 32 位进程不同,显然,这是可行的。
The other alternative is that the third party stuff is actually providing a 64bit reference, and your conclusion of it running 32bit is incorrect.另一种选择是第三方的东西实际上提供了一个 64 位的引用,而你关于它运行 32 位的结论是不正确的。
I'll chalk this up to some complexity in the tonnes of code and projects that the solution consists of.我将把它归结为解决方案所包含的大量代码和项目中的一些复杂性。 Removing the requirements of the offending library to be 64 bits has solved the issue, but naturally doesn't answer the question.将违规库的要求删除为 64 位已经解决了这个问题,但自然不会回答这个问题。 It just makes it obsolete.它只会让它过时。
You.你。 Are.是。 Not.不是。
Point.观点。
Put the web application to 32 bit mode.将 web 应用程序置于 32 位模式。 This is actually how they SHOULD run per MS IIS guidelines (that most people never bother to read).这实际上是他们应该按照 MS IIS 指南运行的方式(大多数人从不费心阅读)。
The w3wp process can run in 32-bit mode and thus can handle 32bit assemblies. w3wp 进程可以在 32 位模式下运行,因此可以处理 32 位程序集。 See whether your IIS service is running in 32-bit mode.查看您的 IIS 服务是否在 32 位模式下运行。
It works through the DllSurrogate mechanism which automatically creates a DllHost process when you try to load a com-dll of the wrong bitness.它通过 DllSurrogate 机制工作,当您尝试加载错误位数的 com-dll 时,该机制会自动创建一个 DllHost 进程。 In those cases you get implicit interprocess communication.在这些情况下,您将获得隐式的进程间通信。 Just take a look at main.看看主要的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.