简体   繁体   English

WCF服务中的COM对象

[英]COM Object in WCF Service

My WCF Service, written in .NET 4.0, has a problem that the second, or any other call get stuck. 我的WCF服务,用.NET 4.0编写,存在第二个或任何其他调用卡住的问题。 The WCF Service does nothing else than calling a COM Object written in Delphi XE. WCF服务除了调用用Delphi XE编写的COM对象之外别无其他。 The threading model is set to Both, the InstanceContextMode of the service is set to PerCall. 线程模型设置为Both,服务的InstanceContextMode设置为PerCall。 The object does not much more than BSTR DoRequest(BSTR Request). 该对象并不比BSTR DoRequest(BSTR请求)多得多。 I use Marshal.ReleaseComObject, but read in an article this is not a good way to clean up com objects; 我使用Marshal.ReleaseComObject,但在文章中读到这不是清理com对象的好方法; i tried it also without. 我也没试过。

I tried the following things: 我尝试了以下事项:

  • added logging to see where the WCF service is stuck. 添加日志记录以查看WCF服务被卡住的位置。 It is inside the COM call. 它在COM调用中。
  • added a unhandled exception handler, but there are no exceptions. 添加了一个未处理的异常处理程序,但没有例外。
  • checked if the Delphi Object uses Static variables 检查Delphi对象是否使用静态变量
  • tried to compile with Delphi XE2 (maybe a bug in the delphi com libraries) 试图用Delphi XE2编译(可能是delphi com库中的一个bug)
  • tried the Object with a multithreaded Delphi stress test tool to see if the problem is the same, but it worked nicely. 尝试使用多线程Delphi压力测试工具来查看问题是否相同,但它运行良好。
  • tried the object with a C# console stress test tool and got the same behaviour as in the WCF Service. 使用C#控制台压力测试工具尝试了该对象,并获得了与WCF服务相同的行为。
  • added a lock object around creating the Object, doing the call and destroying the Object. 在创建Object,执行调用和销毁Object时添加了一个锁定对象。 This did not help. 这没有用。
  • tried to create a new thread inside the WCF and set the threading model to STA; 尝试在WCF中创建一个新线程并将线程模型设置为STA; set the Delphi Object Threading Model to Single. 将Delphi对象线程模型设置为Single。 This did not help. 这没有用。
  • tried to run the Object in the COM+ Services; 试图在COM +服务中运行Object; this did not help. 这没有用。
  • checked the WCF throttling, this is set to 100 检查了WCF限制,将其设置为100
  • checked max connections of the service and set to MaxInt 检查服务的最大连接数并设置为MaxInt

the COM DLL is 32 Bit, so my VStudio Project Settings restrict to x86. COM DLL是32位,所以我的VStudio项目设置限制为x86。 I run on Windows 2008 R2. 我在Windows 2008 R2上运行。 Maybe this does matter: The Delphi COM Object loads a C++ DLL, which might not be treadsafe. 也许这很重要:Delphi COM对象加载一个C ++ DLL,它可能不是特技。

I used Reflector + Dennis Bauer FileDisassembler to decompile the generated COM Wrapper. 我使用Reflector + Dennis Bauer FileDisassembler来反编译生成的COM Wrapper。 I dont see any special in it. 我没有看到任何特别之处。

Using Windebug seems not very easy, as Delphi does not support PDB Files. 使用Windebug似乎不是很容易,因为Delphi不支持PDB文件。

running out of ideas, please help :-) 用完了想法,请帮助:-)

I added a critical section around all calls to the third party dll inside the delphi code. 我在delphi代码中围绕对第三方dll的所有调用添加了一个关键部分。 It looks like it is working now. 看起来它现在正在运作。 This does not explain the behaviour of the com object, but now it seems to work. 这并不能解释com对象的行为,但现在它似乎有效。

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

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