注册和卸载COM

 

///   <summary>
       
///  注册COM+
       
///   </summary>
       
///   <param name="assembly"></param>
       
///   <param name="strErrorMessage"></param>
       
///   <returns></returns>
        public  static  bool Install( string assembly,  ref  string strErrorMessage)
       {
            bool flag =  true;
            string applicationName =  string.Empty;
            string typeLibraryName =  string.Empty;
            try
           {
               flag =  true;
               RegistrationHelper helper =  new RegistrationHelper();
               helper.InstallAssembly(assembly,  ref applicationName,  ref typeLibraryName, InstallationFlags.CreateTargetApplication);
               strErrorMessage =  string.Empty;
           }
            catch (Exception ex)
           {
               flag =  false;
               strErrorMessage = ex.Message;
                // throw;
           }
            return flag;
       }


        ///   <summary>
       
///  卸栽COM+
       
///   </summary>
       
///   <param name="assembly"></param>
       
///   <param name="strErrorMessage"></param>
       
///   <returns></returns>
        public  static  bool UnInstall( string assembly,  ref  string strErrorMessage)
       {
            bool flag =  true;
            string applicationName =  string.Empty;
            string typeLibraryName =  string.Empty;
            try
           {
               flag =  true;
               RegistrationHelper helper =  new RegistrationHelper();
               helper.UninstallAssembly(assembly,  applicationName,  typeLibraryName);
               strErrorMessage =  string.Empty;
           }
            catch (Exception ex)
           {
               flag =  false;
               strErrorMessage = ex.Message;
                // throw;
           }
            return flag;
       }
    } 

  

 

你可能感兴趣的:(com)