本文介绍了Web服务调用排队组件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我有一个Web服务,它在 COM +中调用.NET排队的服务组件。我打开了组件的统计信息。我将组件称为 10次,创建了10个对象,但它们并没有消失。我拨打电话后打电话给 Marshal.ReleaseComObject。 [WebMethod] 公共NotifyResponse通知(NotifyRequest) reqMessage) { 尝试 { string progid =" MyComponent"; MyComponent = (IMyComponent)Marshal.BindToMoniker(" queue:/ new:" + progid); if(MyComponent!= null) { MyComponent.Notify(XMLMessage); } 返回resMessage; } catch(例外e) { ErrorLog.Log(Severity.Error,异常是 抛出:" + e.Message); 返回resMessage; } 终于 { Marshal.ReleaseComObject(MyComponent); } } 解决方案 你的班级派生于IDisposable(ServicedComponent)所以你必须 " dispose"完成后,也就是说,你需要调用MyComponent .Dispose()或使用 使用成语。 using(Mycomponent = ...) { //使用组件...... } //这隐含地调用Dispose Willy。 你的类派生自IDisposable(ServicedComponent)所以你必须 " dispose"完成后,也就是说,你需要调用MyComponent .Dispose()或 使用习惯用法。 使用(Mycomponent = ...) { //使用组件...... } //这隐含地调用Dispose Willy。 抱歉,我错过了Moniker,你有效地获得了一个COM包装器,所以你需要调用ReleaseComObject。 需要调查一下,完成后我会回来的。 Willy。 抱歉,我错过了Moniker,你有效地获得了一个COM包装器,所以你需要调用ReleaseComObject来获得。 需要调查一下,完成后我会回来的。 Willy.-隐藏引用的文字 - - 显示引用的文字 - 非常感谢!我会晕厥 I have a web service which calls a .NET queued serviced component inCOM+. I turned statistics on for the component. I call the component10 times, 10 objects get created but they do not go away. I''m callingMarshal.ReleaseComObject after I make each call. [WebMethod]public NotifyResponse Notify(NotifyRequest reqMessage){try{string progid = "MyComponent";MyComponent=(IMyComponent)Marshal.BindToMoniker("queue:/new:" + progid);if ( MyComponent != null){MyComponent.Notify(XMLMessage);}return resMessage;}catch (Exception e){ErrorLog.Log(Severity.Error, "An exception wasthrown:" + e.Message);return resMessage;}finally{Marshal.ReleaseComObject(MyComponent);}} 解决方案 Your class derives from an IDisposable (ServicedComponent) so you have to"dispose" when done, that is, you need to call MyComponent .Dispose() or usethe using idiom. using (Mycomponent = ...){// use the component...} //this implicitly calls DisposeWilly. Your class derives from an IDisposable (ServicedComponent) so you have to"dispose" when done, that is, you need to call MyComponent .Dispose() oruse the using idiom.using (Mycomponent = ...){ // use the component...} //this implicitly calls DisposeWilly. Sorry, I missed the Moniker, you effectively get a COM wrapper back, so youneed to call ReleaseComObject.Need to investigate this a bit, i''ll come back when done. Willy. Sorry, I missed the Moniker, you effectively get a COM wrapper back, so youneed to call ReleaseComObject.Need to investigate this a bit, i''ll come back when done.Willy.- Hide quoted text -- Show quoted text -Thanks so much! I''ll be wainting 这篇关于Web服务调用排队组件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-12 19:05