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

news/2024/6/17 8:02:13
整理者 郑昀@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


    }

}




http://www.niftyadmin.cn/n/3649362.html

相关文章

bat命令行遍历文件_命令行基础知识:如何遍历目录中的文件

bat命令行遍历文件Looping is one of the most powerful things you can do in programming. It allows you to apply the same logic over and over to a group of items with minimal code. If done properly, infinite loops can be a blessing instead of a curse. Unfortu…

ndk的入门

第一个ndk 第一步:MainActivity中定义一个方法: public static native String getStringFromC(); 第二步生成头文件: ①我的项目位置:E:\android\HelloNdk ②我的sdk中android.jar包的位置:G:\android\AndroidX86\AndroidX86\sdk\platfor…

CentOS 7安装并配置Nginx

Nginx是一款轻量级的Web 服务器/反向代理服务器及电子邮件(IMAP/POP3)代理服务器,在BSD-like 协议下发行。其特点是占有内存少,并发能力强,事实上nginx的并发能力在同类型的网页服务器中表现较好,中国大陆使…

spring react_如何使用React Spring创建动画的React应用

spring react介绍 (Introduction) Animations add life to your applications and improve the overall user experience. React Spring is an animation package that uses spring-like physics in its core animations to make it easily configurable. Springs are cumulati…

[GOLF]过了磨合期了

今日到了4S店,换了三滤,检查了胎压和空调。换了三滤果然很见效,回去的路上,就觉得爱车凶猛了许多,很给劲儿。第一次开着车去了王府井,并且第一次停到了收费的地下停车场,蜿蜒着下到地下&#xf…

CentOS 7搭建PHP环境

PHP即“超文本预处理器”,是一种通用开源脚本语言。PHP是在服务器端执行的脚本语言,与C语言类似,是常用的网站编程语言。PHP独特的语法混合了C、Java、Perl以及 PHP 自创的语法。利于学习,使用广泛,主要适用于Web开发领…

Android Context 详解

Android中context可以作很多操作,但是最主要的功能是加载和访问资源。 在android中有两种context,一种是application context,一种是activity context,通常我们在各种类和方法间传递的是activity context。 继承关系:…

如何在JavaScript中替换字符串的所有实例

介绍 (Introduction) Replacing text in strings is a common task in JavaScript. In this article you’ll look at using replace and regular expressions to replace text. 替换字符串中的文本是JavaScript中的常见任务。 在本文中,您将研究如何使用replace和正…