[EnterpriseServices]利用assembly定义我们的组件在COM+中的注册方式

来源:互联网 发布:c语言void用法 编辑:程序博客网 时间:2024/05/12 14:21
整理者 郑昀@UltraPower

利用以下assembly定义我们的组件在COM+中的注册方式,其中:

ApplicationName 属性是"COM+ 目录""组件服务管理"控制台中显示的 COM+ 应用程序的名称。

[assembly: ApplicationName("MyDLL.Interface")]

Description属性为"COM+ 目录""组件服务管理"控制台中的 COM+ 应用程序提供说明。

[assembly: Description("My Serviced Component")]

ActivationOption 属性指示是否在调用方的进程中激活组件。我们这里将 Activation.Option 设置为服务器,意即“组件将在专用服务器进程中被激活”。

[assembly:ApplicationActivation(ActivationOption.Server)]

ApplicationAccessControl属性设置访问管理和验证级别。这里我们设置:不对此应用程序强制进行访问权限检查;调用的身份验证级别为无;模拟级别为委派。

[assembly: ApplicationAccessControl(Value=false,

                                  ImpersonationLevel=ImpersonationLevelOption.Delegate,

                                  Authentication=AuthenticationOption.None)]

代码中实现了以上定义后,就可以简单地通过
regsvcs MyDLL.DLL或者通过下面的类定义来注册我们的COM+组件,调用方法是:
“string strComPlusDLLFilePath  = RootForumsDirectory + @"/bin/MyDLL.dll";
    UltraPower.InstallClassLib.InstallClassRegsvcs.Install(strComPlusDLLFilePath);”
就可以免手工配置COM+应用了,省去了许多麻烦。

namespace UltraPower.InstallClassLib
{
    
public class InstallClassRegsvcs
    
{
        
public InstallClassRegsvcs()
        
{
        }


        
#region Install
        
//---Override the 'Install' method.
        public static void Install(string strComPlusDLLFilePath)
        
{
            
//---checkpoint 
            Trace.WriteLine(string.Format("注册COM+组件 {0}", strComPlusDLLFilePath));
            
            
//---action
            Process installProcess = new Process();
            ProcessStartInfo installInfo 
= new ProcessStartInfo("regsvcs.exe");
            installInfo.Arguments 
= " " + strComPlusDLLFilePath;    
            installInfo.WindowStyle 
= ProcessWindowStyle.Hidden;
            installProcess.StartInfo 
= installInfo;

            
//run
            installProcess.Start();
            installProcess.WaitForExit();            
                
        }

        
#endregion


    }

}

namespace UltraPower.InstallClassLib
{
    
public class InstallClassRegsvcs
    
{
        
public InstallClassRegsvcs()
        
{
        }


        
#region Install
        
//---Override the 'Install' method.
        public static void Install(string strComPlusDLLFilePath)
        
{
            
//---checkpoint 
            Trace.WriteLine(string.Format("注册COM+组件 {0}", strComPlusDLLFilePath));
            
            
//---action
            Process installProcess = new Process();
            ProcessStartInfo installInfo 
= new ProcessStartInfo("regsvcs.exe");
            installInfo.Arguments 
= " " + strComPlusDLLFilePath;    
            installInfo.WindowStyle 
= ProcessWindowStyle.Hidden;
            installProcess.StartInfo 
= installInfo;

            
//run
            installProcess.Start();
            installProcess.WaitForExit();            
                
        }

        
#endregion


    }

}



整理者 郑昀@UltraPower

利用以下assembly定义我们的组件在COM+中的注册方式,其中:

ApplicationName 属性是"COM+ 目录""组件服务管理"控制台中显示的 COM+ 应用程序的名称。

[assembly: ApplicationName("MyDLL.Interface")]

Description属性为"COM+ 目录""组件服务管理"控制台中的 COM+ 应用程序提供说明。

[assembly: Description("My Serviced Component")]

ActivationOption 属性指示是否在调用方的进程中激活组件。我们这里将 Activation.Option 设置为服务器,意即“组件将在专用服务器进程中被激活”。

[assembly:ApplicationActivation(ActivationOption.Server)]

ApplicationAccessControl属性设置访问管理和验证级别。这里我们设置:不对此应用程序强制进行访问权限检查;调用的身份验证级别为无;模拟级别为委派。

[assembly: ApplicationAccessControl(Value=false,

                                  ImpersonationLevel=ImpersonationLevelOption.Delegate,

                                  Authentication=AuthenticationOption.None)]

代码中实现了以上定义后,就可以简单地通过
regsvcs MyDLL.DLL或者通过下面的类定义来注册我们的COM+组件,调用方法是:
“string strComPlusDLLFilePath  = RootForumsDirectory + @"/bin/MyDLL.dll";
    UltraPower.InstallClassLib.InstallClassRegsvcs.Install(strComPlusDLLFilePath);”
就可以免手工配置COM+应用了,省去了许多麻烦。

namespace UltraPower.InstallClassLib
{
    
public class InstallClassRegsvcs
    
{
        
public InstallClassRegsvcs()
        
{
        }


        
#region Install
        
//---Override the 'Install' method.
        public static void Install(string strComPlusDLLFilePath)
        
{
            
//---checkpoint 
            Trace.WriteLine(string.Format("注册COM+组件 {0}", strComPlusDLLFilePath));
            
            
//---action
            Process installProcess = new Process();
            ProcessStartInfo installInfo 
= new ProcessStartInfo("regsvcs.exe");
            installInfo.Arguments 
= " " + strComPlusDLLFilePath;    
            installInfo.WindowStyle 
= ProcessWindowStyle.Hidden;
            installProcess.StartInfo 
= installInfo;

            
//run
            installProcess.Start();
            installProcess.WaitForExit();            
                
        }

        
#endregion


    }

}

namespace UltraPower.InstallClassLib
{
    
public class InstallClassRegsvcs
    
{
        
public InstallClassRegsvcs()
        
{
        }


        
#region Install
        
//---Override the 'Install' method.
        public static void Install(string strComPlusDLLFilePath)
        
{
            
//---checkpoint 
            Trace.WriteLine(string.Format("注册COM+组件 {0}", strComPlusDLLFilePath));
            
            
//---action
            Process installProcess = new Process();
            ProcessStartInfo installInfo 
= new ProcessStartInfo("regsvcs.exe");
            installInfo.Arguments 
= " " + strComPlusDLLFilePath;    
            installInfo.WindowStyle 
= ProcessWindowStyle.Hidden;
            installProcess.StartInfo 
= installInfo;

            
//run
            installProcess.Start();
            installProcess.WaitForExit();            
                
        }

        
#endregion


    }

}



整理者 郑昀@UltraPower

利用以下assembly定义我们的组件在COM+中的注册方式,其中:

ApplicationName 属性是"COM+ 目录""组件服务管理"控制台中显示的 COM+ 应用程序的名称。

[assembly: ApplicationName("MyDLL.Interface")]

Description属性为"COM+ 目录""组件服务管理"控制台中的 COM+ 应用程序提供说明。

[assembly: Description("My Serviced Component")]

ActivationOption 属性指示是否在调用方的进程中激活组件。我们这里将 Activation.Option 设置为服务器,意即“组件将在专用服务器进程中被激活”。

[assembly:ApplicationActivation(ActivationOption.Server)]

ApplicationAccessControl属性设置访问管理和验证级别。这里我们设置:不对此应用程序强制进行访问权限检查;调用的身份验证级别为无;模拟级别为委派。

[assembly: ApplicationAccessControl(Value=false,

                                  ImpersonationLevel=ImpersonationLevelOption.Delegate,

                                  Authentication=AuthenticationOption.None)]

代码中实现了以上定义后,就可以简单地通过
regsvcs MyDLL.DLL或者通过下面的类定义来注册我们的COM+组件,调用方法是:
“string strComPlusDLLFilePath  = RootForumsDirectory + @"/bin/MyDLL.dll";
    UltraPower.InstallClassLib.InstallClassRegsvcs.Install(strComPlusDLLFilePath);”
就可以免手工配置COM+应用了,省去了许多麻烦。

namespace UltraPower.InstallClassLib
{
    
public class InstallClassRegsvcs
    
{
        
public InstallClassRegsvcs()
        
{
        }


        
#region Install
        
//---Override the 'Install' method.
        public static void Install(string strComPlusDLLFilePath)
        
{
            
//---checkpoint 
            Trace.WriteLine(string.Format("注册COM+组件 {0}", strComPlusDLLFilePath));
            
            
//---action
            Process installProcess = new Process();
            ProcessStartInfo installInfo 
= new ProcessStartInfo("regsvcs.exe");
            installInfo.Arguments 
= " " + strComPlusDLLFilePath;    
            installInfo.WindowStyle 
= ProcessWindowStyle.Hidden;
            installProcess.StartInfo 
= installInfo;

            
//run
            installProcess.Start();
            installProcess.WaitForExit();            
                
        }

        
#endregion


    }

}

namespace UltraPower.InstallClassLib
{
    
public class InstallClassRegsvcs
    
{
        
public InstallClassRegsvcs()
        
{
        }


        
#region Install
        
//---Override the 'Install' method.
        public static void Install(string strComPlusDLLFilePath)
        
{
            
//---checkpoint 
            Trace.WriteLine(string.Format("注册COM+组件 {0}", strComPlusDLLFilePath));
            
            
//---action
            Process installProcess = new Process();
            ProcessStartInfo installInfo 
= new ProcessStartInfo("regsvcs.exe");
            installInfo.Arguments 
= " " + strComPlusDLLFilePath;    
            installInfo.WindowStyle 
= ProcessWindowStyle.Hidden;
            installProcess.StartInfo 
= installInfo;

            
//run
            installProcess.Start();
            installProcess.WaitForExit();            
                
        }

        
#endregion


    }

}



整理者 郑昀@UltraPower

利用以下assembly定义我们的组件在COM+中的注册方式,其中:

ApplicationName 属性是"COM+ 目录""组件服务管理"控制台中显示的 COM+ 应用程序的名称。

[assembly: ApplicationName("MyDLL.Interface")]

Description属性为"COM+ 目录""组件服务管理"控制台中的 COM+ 应用程序提供说明。

[assembly: Description("My Serviced Component")]

ActivationOption 属性指示是否在调用方的进程中激活组件。我们这里将 Activation.Option 设置为服务器,意即“组件将在专用服务器进程中被激活”。

[assembly:ApplicationActivation(ActivationOption.Server)]

ApplicationAccessControl属性设置访问管理和验证级别。这里我们设置:不对此应用程序强制进行访问权限检查;调用的身份验证级别为无;模拟级别为委派。

[assembly: ApplicationAccessControl(Value=false,

                                  ImpersonationLevel=ImpersonationLevelOption.Delegate,

                                  Authentication=AuthenticationOption.None)]

代码中实现了以上定义后,就可以简单地通过
regsvcs MyDLL.DLL或者通过下面的类定义来注册我们的COM+组件,调用方法是:
“string strComPlusDLLFilePath  = RootForumsDirectory + @"/bin/MyDLL.dll";
    UltraPower.InstallClassLib.InstallClassRegsvcs.Install(strComPlusDLLFilePath);”
就可以免手工配置COM+应用了,省去了许多麻烦。

namespace UltraPower.InstallClassLib
{
    
public class InstallClassRegsvcs
    
{
        
public InstallClassRegsvcs()
        
{
        }


        
#region Install
        
//---Override the 'Install' method.
        public static void Install(string strComPlusDLLFilePath)
        
{
            
//---checkpoint 
            Trace.WriteLine(string.Format("注册COM+组件 {0}", strComPlusDLLFilePath));
            
            
//---action
            Process installProcess = new Process();
            ProcessStartInfo installInfo 
= new ProcessStartInfo("regsvcs.exe");
            installInfo.Arguments 
= " " + strComPlusDLLFilePath;    
            installInfo.WindowStyle 
= ProcessWindowStyle.Hidden;
            installProcess.StartInfo 
= installInfo;

            
//run
            installProcess.Start();
            installProcess.WaitForExit();            
                
        }

        
#endregion


    }

}

namespace UltraPower.InstallClassLib
{
    
public class InstallClassRegsvcs
    
{
        
public InstallClassRegsvcs()
        
{
        }


        
#region Install
        
//---Override the 'Install' method.
        public static void Install(string strComPlusDLLFilePath)
        
{
            
//---checkpoint 
            Trace.WriteLine(string.Format("注册COM+组件 {0}", strComPlusDLLFilePath));
            
            
//---action
            Process installProcess = new Process();
            ProcessStartInfo installInfo 
= new ProcessStartInfo("regsvcs.exe");
            installInfo.Arguments 
= " " + strComPlusDLLFilePath;    
            installInfo.WindowStyle 
= ProcessWindowStyle.Hidden;
            installProcess.StartInfo 
= installInfo;

            
//run
            installProcess.Start();
            installProcess.WaitForExit();            
                
        }

        
#endregion


    }

}



原创粉丝点击