[C#]服务为何会依赖于WMI Performance Adapter服务

<iframe align="center" marginwidth="0" marginheight="0" src="http://www.zealware.com/csdnblog336280.html" frameborder="0" width="336" scrolling="no" height="280"></iframe>

[C#]服务为何会依赖于WMI Performance Adapter服务

编写者

日期

关键词

<personname w:st="on"><span style="COLOR: gray; FONT-FAMILY: 宋体; mso-bidi-font-family: Arial; mso-ascii-font-family: Arial; mso-hansi-font-family: " times new roman>郑昀</span></personname>@ultrapower

<chsdate w:st="on" isrocdate="False" islunardate="False" day="13" month="6" year="2005"><span lang="EN-US" style="COLOR: gray; FONT-FAMILY: Arial">2005-6-13</span></chsdate>

Service C# Cache

“WMI Performance Adapter”

“Microsoft Enterprise Library”

现象

我们的C#编写的Windows ServiceCommandListener”在Windows 2000上运行正常,但是在Windows 2003上却总是依赖于“WMI Performance Adapter”服务的启动。

而“WMI Performance Adapter”服务一般是手动启动的,这样就导致服务器重启之后,“CommandListener”服务没有能够自动启动。

但是却找不到是哪一个部分依赖于这个“WMI Performance Adapter”。

经过逐个排查,确定是添加了对“Microsoft Enterprise Library”的“Microsoft.Practices.EnterpriseLibrary.Caching.dll”的使用导致的。

探求究竟

System.Management.Instrumentation引发的

由于Microsoft.Practices.EnterpriseLibrary.Caching工程中,有对“System.Management.Instrumentation”的引用。

而这个“System.Management.Instrumentation”命名空间提供一些类,提供在规范应用程序管理并通过 WMI 向潜在使用者公开管理信息和事件时必需的类。这样,Microsoft Application Center Microsoft Operations Manager 等使用者就可以轻松地管理您的应用程序,而管理员脚本或其他应用程序(托管应用程序和非托管应用程序)也可以监视和配置您的应用程序。

也就是说,正是因为Microsoft.Practices.EnterpriseLibrary.Caching,所以为服务引入了“WMI Performance Adapter”服务的依赖性。

解决办法:

由于没办法通过Cache自身的配置解除对“WMI Performance Adapter”服务的依赖,我们只能主动给“CommandListener”服务加上相关服务依赖性,这样让我们的服务能够成功自动启动。

通过以下代码,就可以:

Code

[RunInstaller(true)]

public class ProjectInstaller : System.Configuration.Install.Installer

{

private System.ServiceProcess.ServiceProcessInstaller serviceProcessInstaller1;

private Verifide.ServiceUtils.ServiceInstallerEx serviceInstaller1; this.serviceInstaller1.ServicesDependedOn = new string[] {

"WMI Performance Adapter"};

编写者

日期

关键词

<personname w:st="on"><span style="COLOR: gray; FONT-FAMILY: 宋体; mso-bidi-font-family: Arial; mso-ascii-font-family: Arial; mso-hansi-font-family: " times new roman>郑昀</span></personname>@ultrapower

<chsdate w:st="on" isrocdate="False" islunardate="False" day="13" month="6" year="2005"><span lang="EN-US" style="COLOR: gray; FONT-FAMILY: Arial">2005-6-13</span></chsdate>

Service C# Cache

“WMI Performance Adapter”

“Microsoft Enterprise Library”




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值