C ++ CLI DLL没有被加载IIS7但只有用什么比VS2008建新 [英] C++ CLI DLL not being loaded by IIS7 but only if built with anything newer than VS2008

查看:238
本文介绍了C ++ CLI DLL没有被加载IIS7但只有用什么比VS2008建新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有关我使用Windows 7旗舰版64位我的开发环境,使用VS2008,V2010和VS2013,我的应用程序是用C#。

For my development environment I'm using Windows 7 Ultimate x64, with VS2008, V2010 and VS2013, and my application is written in C#.

远程测试服务器的Windows Web Server 2008 R2的x64和IIS 7。

The remote test server has Windows Web Server 2008 R2 x64 and IIS 7.

下面是我的具体问题:

我有++库,我想在我的C#应用​​程序使用本机C,所以我写了一个C ++ CLI / CLR包装周围,而这一切编译成同一个DLL。我都试过编译C ++源代码到DLL,而且静态本地库链接到DLL,无一不给我相同的结果,如下所述。

I have a native C++ library that I want to use in my C# applications, so I wrote a C++ CLI/CLR wrapper around it, and compiled it all into the same DLL. I've tried both compiling the C++ source into the DLL, and also statically linking the native library into the DLL, and both give me the same result as described below.

如果我建立使用x64和.NET 4.5.1与VS2013这个DLL,那么这个DLL工作正常进出发展环境的任何C#WinForms应用程序。在我的开发环境(使用64 IIS防爆preSS测试)在ASP.NET应用程序中引用时,它也可以。当部署Web应用程序(为64版本)到Win2K8 IIS7服务器,显示一个BadImageFormatException这是行不通的。我不建立值为anycpu,因为CLI包装DLL,它需要针对特定​​平台要建的。

If I build this DLL using x64 and .NET 4.5.1 with VS2013, then this DLL works fine with any C# Winforms application in and out of the development environment. It also works when referenced in an ASP.NET application within my development environment (using x64 IIS Express to test). It does NOT work when the web application is deployed (as an x64 build) to the Win2K8 IIS7 server, displaying an BadImageFormatException. I do not build for "AnyCPU" because of the CLI wrapper DLL, which needs to be built for a specific platform.

我也试过CLI DLL(使用VS2013)的.NET4.5.1 x86版,它也能正常工作与所有的WinForms应用程序,以及ASP.NET工作我的开发机(使用86 IIS防爆$ P上$ PSS),但它不会对Win2K8 IIS7服务器(86构建工作)。尝试加载这个DLL时一样BadImageFormatException错误。

I have also tried the .NET4.5.1 x86 version of the CLI DLL (using VS2013), and it also works fine with all Winforms applications, and works with ASP.NET on my development machine (using x86 IIS Express), but it does not work on the Win2K8 IIS7 server (x86 build). Same BadImageFormatException error when trying to load this DLL.

在服务器,它使用,因为ASP.NET身份code的集成应用程序池(不会让我使用经典模式)。此外,32位应用程序设置已切换到两个真/假,也不帮助解决了这个问题。

On the server it uses an integrated application pool because of the ASP.NET Identity code (won't let me use Classic mode). Also, the "32-bit applications" setting has been toggled to both True/False, and neither has helped solve this issue.

如果我建C ++ CLI DLL的.NET 2或.NET 3.5和x86平台与VS2008,甚至VS2013,但VS2008选择(V90)为平台工具,那么它完美罚款Win2K8 IIS7服务器上,没有BadImageFormatException错误。 ASP.NET的集成应用程序池32位应用程序设置为真为了这个工作。

If I build the C++ CLI DLL for .NET 2 or .NET 3.5 and the x86 platform with VS2008, or even VS2013, but selecting VS2008 (V90) as the platform toolset, then it works perfectly fine on the Win2K8 IIS7 server, with no BadImageFormatException error. The ASP.NET integrated app pool "32-bit applications" setting is "True" in order for this to work.

如果我构建C ++ CLI DLL作为.NET 2或3.5,x86平台,但什么比VS2008的工具更新,它无法在IIS服务器上加载,具有BadImageFormatException,尽管它工作正常的开发机器上ASP.NET在任何WinForms应用程序。

If I build the C++ CLI DLL as .NET 2 or 3.5, x86 platform, but with anything newer than the VS2008 toolset, it fails to load on the IIS server, with BadImageFormatException, even though it works fine on the development machine ASP.NET and in any Winforms application.

使用VS2008,.NET 2或3.5和平台64时,DLL可以在任何应用程序的WinForms,在开发机器上ASP.NET/IIS防爆preSS x64的作品,但不会对Win2K8 IIS7工作服务器,显示BadImageFormatException。应用程序池的32位应用程序设置为真假两进行测试。

Using VS2008, .NET 2 or 3.5, and platform x64, the DLL works in any Winforms app, works with ASP.NET/IIS Express x64 on the development machine, but does NOT work on the Win2K8 IIS7 server, displaying BadImageFormatException. The application pool "32-bit applications" was set to both True and False for testing.

所以,总的看来,在IIS7工作的唯一选择情况下选择了x86平台的建设,使用VS2008(V90)的工具集。

So, in summary, the only option that works on IIS7 is building with the x86 platform selected, using the VS2008 (V90) toolset.

有没有人经历过这样的事或者有一个想法是什么可能会导致此问题。我什么都看不到工作DLL和使用JetBrains公司dotNetPeek 1.1他人完全不同的方法,但是这只有真正一看表面......在存在的所有code。莫不是在在DLL中嵌入的东西(或留下一些东西的话)的V100或更高版本工具集,导致它不能在IIS7加载选项?

Has anyone experienced anything like this or have an idea what may be causing this issue. I can't see anything drastically different between the working DLL and the others using JetBrains dotNetPeek 1.1, but that's only really a look at the surface... all the code exists in there. Could there be an option in the V100 or higher toolset that is embedding something in the DLL (or leaving something out of it) that is causing it to not be loaded on IIS7?

任何帮助或建议将是AP preciated。

Any help or suggestions would be appreciated.

推荐答案

好了,所以现在这个问题挣扎了将近一个月,并诉诸要求对在这里的最后一夜后,我遇到这些链接就来了:

Ok, so after struggling with this issue for almost a month now, and resorting to asking on here last night, I came across these links:

<一个href=\"http://stackoverflow.com/questions/23373615/identifying-problematic-dependencies-in-c-cli-project\">Identifying在C ++ / CLI项目问题的相关性

HTTP://www.$c$cproject.com /文章/ 442784 /最佳陷阱 - 的 - CPLUSPLUS-CLI

虽然他们实际上并没有指定的解决方案,有东西在那里,我还没有尝试过,这是检查是否在Windows 2008 R2服务器所需的VS2013 C ++可再发行组件包。

While they didn't actually specify the solution, there was something in there that I hadn't tried yet, which was to check if the Windows 2008 R2 server required the VS2013 C++ redistributable packages.

我安装在x86都和x64的可再发行组件包,并使用了++库来生活的本地C的托管C ++包装突然我的64 ASP.NET应用程序。一切工作作为目前打算。我可以编译与VS2013工具集,x64平台的包装DLL,使用.NET的V4.5.1版本,和它的作品完美的罚款。我不再需要VS2008工具。

I installed both the x86 and the x64 redistributable packages, and suddenly my x64 ASP.NET app that uses the managed C++ wrapper for the native C++ library came to life. Everything is working as intended now. I can compile the wrapper DLL with the VS2013 toolset, x64 platform, using v4.5.1 of .NET, and it works perfectly fine. I no longer require the VS2008 toolset.

这么多BadImageFormatException扔我完全关闭。我希望赢2K8 IIS7服务器上显示的错误实际上是更具体的,但话又说回来,也许这只是我的要求太高。

So much for BadImageFormatException throwing me off completely. I wish the error displayed on the Win 2K8 IIS7 server was actually more specific, but then again maybe that is just me asking for too much.

我希望这可以帮助别人。

I hope this helps someone else.

这篇关于C ++ CLI DLL没有被加载IIS7但只有用什么比VS2008建新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆