简体   繁体   English

在IIS 7中使用COM对象

[英]Use of COM object in IIS 7

I am currently moving an ASP.NET web-project from an IIS 6 to a IIS 7 hosting environment. 我目前正在将ASP.NET Web项目从IIS 6迁移到IIS 7托管环境。 Everything seems to be running OK, except my calls to a COM object. 除了我对COM对象的调用外,其他一切似乎都运行正常。

I can perfectly instantiate an object of the COM type, but when I call one of its methods, the IIS crashes. 我可以完美地实例化COM类型的对象,但是当我调用其方法之一时,IIS将崩溃。 The event log reports an error code "0xc0000374", which indicates a heap corruption. 事件日志报告错误代码“ 0xc0000374”,指示堆损坏。

When I run the application inside the visual studio development server, everything goes well and the COM object code gets executed without any errors. 当我在Visual Studio开发服务器中运行该应用程序时,一切顺利,并且COM对象代码得以正确执行。 This is also the case when the application is hosted on an IIS 6 machine. 当应用程序托管在IIS 6计算机上时,也是如此。

I have looked through all settings of the IIS 7 and have not found anything configurable for COM objects, like security or ... 我查看了IIS 7的所有设置,但未找到可为COM对象配置的任何内容,例如安全性或...

I have been struggling with this for a while and I'm out of ideas. 我已经为此苦苦挣扎了一段时间,但我没有想法。 Does anyone have any experience deploying COM objects on IIS 7? 有没有人有在IIS 7上部署COM对象的经验?

Your help would be very appreciated! 您的帮助将不胜感激!

据我所记得,COM对象需要在服务器上注册,方法是使用regsvr32,甚至最好在“控制面板”>“管理工具”>“组件服务”中添加这些对象?

Phew... I found the solution!! ew ...我找到了解决方案!

The Delphi COM object I am using, was returning a string that holds the path to the generated image file. 我正在使用的Delphi COM对象正在返回一个字符串,其中包含生成的图像文件的路径。 Because the Delphi code gave that string as a result, or return value for C# developers. 因为Delphi代码给出了该字符串的结果,或者为C#开发人员返回了值。 The memory allocated for that variable was inaccessible for my C# code, which resulted in the heap corruption or error code "0xc0000374". 我的C#代码无法访问为该变量分配的内存,这导致堆损坏或错误代码“ 0xc0000374”。

I solved it by rewriting the Delphi code to accept a "ref" variable for the file path, so it would write to the same pointer as the string variable I create in C#. 我通过重写Delphi代码以接受文件路径的“ ref”变量来解决该问题,因此它将与在C#中创建的字符串变量写入同一指针。

Lucky for my I have access to the COM object source code... 幸运的是我可以访问COM对象源代码...

I got the inspiration from the following article: 我从以下文章中得到了启发:

http://blogs.msdn.com/b/asiatech/archive/2009/12/24/net-application-may-crash-on-windows-2008-when-calling-function-from-native-c-dll.aspx http://blogs.msdn.com/b/asiatech/archive/2009/12/24/net-application-may-crash-on-windows-2008-when-calling-function-from-native-c-dll。 aspx

I hope this can help other people in the future. 我希望这可以在将来对其他人有所帮助。

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

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