管理远程 WMI 连接
我主要使用 VBScript 进行编码,并且对我正在编写的 C# ASP.NET 应用程序有一个疑问,该应用程序将执行远程 WMI 信息查询(特别是系统中心配置管理器 (SCCM))。 Config Mgr 2007 的 SDK (http://msdn.microsoft.com/en-us/library/cc145284.aspx) 中显示的示例显示了正在创建到远程服务器的连接并调用另一个类中的代码片段(方法)。但是,在这个应用程序中,我会对远程服务器进行多次调用,我很好奇 C# 如何管理和关闭此连接?如果我调用多个“snipplet”,它是否会维护与服务器的单个连接,或者每个调用的“snipplet”都会创建与服务器的新连接。我担心的是与服务器有 300 个连接,因为我没有看到 .Close 或任何连接清理。我只想确保我的类正确构建,并且在继续构建我的应用程序之前不会与远程服务器建立大量连接。感谢您的任何意见。
I code in mostly VBScript and have a question regarding a C# ASP.NET application that I'm writing that will do remote WMI queries for information (specifically to Systems Center Configuration Manager (SCCM)). The examples shown in the SDK (http://msdn.microsoft.com/en-us/library/cc145284.aspx) for Config Mgr 2007 show a connection being created to the remote server and calling snipplets (methods) in another class. However, in this application I would be making numerous calls to the remote server and I'm curious to know how C# manages and closes this connection? If I called multiple 'snipplets', does it maintain a single connection to the server or would each 'snipplet' called create a new connection to the server. My concern is having 300 connections to the server because I don't see an .Close or any cleanup of the connection. I would just like to ensure my class is built properly and not making a multitude of connections to the remote server before I continue building my application. Thanks for any input.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你在哪里看到这 300 个连接?
网络管理类最终基于 WMI COM 接口和类;即使在那里,您也会缺少“关闭”。据我认为[:-)]
根据我的经验,如果您的连接会自动消失
物品均已妥善处置。
我的建议是,首先创建一个 ManagementScope 并全部使用它
其他方法和查询中的时间。最后,摆脱它。
您应该展示您的一种方法,以变得更加具体!
br++马布拉
Where do you see these 300 connections??
Net management Classes are finally based on the WMI COM interfaces and classes;Even there, you'll missing a "Close". From what I think [ :-) ]
and my experience, the connection will disappear automatically, if your
objects are all properly disposed.
What I recommend, is, create a ManagementScope first and use it all
the time in your other methods and queries. Finally, get rid of it.
You should show one of your methods, to become more specific!
br++mabra