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

 

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

编写者

日期

关键词

郑昀@ultrapower

2005-6-13

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"};

 

编写者

日期

关键词

郑昀@ultrapower

2005-6-13

Service C# Cache

“WMI Performance Adapter”

“Microsoft Enterprise Library”

 

posted @ 2005-06-13 13:49  旁观者  阅读(4681)  评论(1编辑  收藏  举报