zoukankan      html  css  js  c++  java
  • Windows服务ServicesDependedOn的奇怪问题?

    Windows服务ServicesDependedOn的奇怪问题???

    代码如下

    public partial class WinServicePWServiceInstaller : Installer

        {

     

            private ServiceProcessInstaller process;

            private ServiceInstaller service;

            private const string m_SERVICENAME = "myService";

     

            public WinServicePWServiceInstaller()

            {

     

                InitializeComponent();

     

                process = new ServiceProcessInstaller();

                process.Account = ServiceAccount.LocalSystem;

     

              

                service = new ServiceInstaller();

                service.ServiceName =m_SERVICENAME;

                service.StartType = ServiceStartMode.Automatic;

                service.ServicesDependedOn = GetDepengOnServices();

     

                Installers.Add(process);

                Installers.Add(service);

     

            }

            /// <summary>

            ///获取配置文件的依赖服务

            /// </summary>

            /// <returns></returns>

            private string[] GetDepengOnServices()

            {

                string[] services=null;                              

                string allService = ConfigurationManager.AppSettings["DependOnService"];

                services = new string[] { allService };

                //return services;

                if (allService.IndexOf(';') != -1)

                {

                   services = allService.Split(';');

                }

                else

               {

                   services =new string[]{ allService};

               }

               return services;

     

            }

        }               

    按以上方法写的 GetDepengOnServices(),在安装过程中报错。

    改成一下方法不会报错

    /// <summary>

            ///获取配置文件的依赖服务

            /// </summary>

            /// <returns></returns>

          private string[] GetDepengOnServices()

            {

                string[] services=null;                              

                string allService = ConfigurationManager.AppSettings["DependOnService"];

                services = new string[] { allService };

                return services;

                //if (allService.IndexOf(';') != -1)

                //{

                //    services = allService.Split(';');

                //}

                //else

                //{

                //    services =new string[]{ allService};

                //}

                //return services;

     

            }                  

    所读的配置节 <!--本服务依赖的服务列表-->

        <add key ="DependOnService" value ="MSSQLSERVER"/>

    跟踪后,两种写法都能得出正确的结果,为什么 第一种写法在安装过程中会报错????

  • 相关阅读:
    metal的gpu query
    体积雾 global fog unity 及改进
    hdr rt format对颜色的影响
    unity deferred lighting
    unity linear space时 photoshop blend的正确设置
    unity linear work flow
    一些数据 bandwidth之类
    deferred rendering with msaa
    unity 显示mipmaplevel
    【转】在C#中使用SendMessage
  • 原文地址:https://www.cnblogs.com/hbb0b0/p/1581766.html
Copyright © 2011-2022 走看看