首 页 | 新 闻 | 技术中心 | 第二书店 | 《程序员》 | 《开发高手》 | 社 区 | 黄 页 | 人 才
移 动专 题SUNIBM微 软微 创精 华Donews人 邮
我的技术中心 
我的分类 我的文档
全部文章 发表文章
专栏管理 使用说明



 RSS 订阅 
最新文档列表
Windows/.NET
.NET  (rss)    
Visual C++  (rss)    
Delphi  (rss)    
Visual Basic  (rss)    
ASP  (rss)    
JavaScript  (rss)    
Java/Linux
Java  (rss)    
Perl  (rss)    
综合
其他开发语言  (rss)    
文件格式  (rss)    
企业开发
游戏开发  (rss)    
网站制作技术  (rss)    
数据库
数据库开发  (rss)    
软件工程
其他  (rss)    

积极原创作者 
capsicum29 (8)
qdzx2008 (51)
ShowLong (1)
cyp403 (16)
yjz0065 (114)
lphpc (31)
smallnest (63)
tellmenow (22)
cutemouse (22)
softj (78)
CSDN - 文档中心 - .NET 阅读:2296   评论: 0    参与评论
标题   [EnterpriseServices]利用assembly定义我们的组件在COM+中的注册方式      选择自 zhengyun_ustc 的 Blog
关键字   [EnterpriseServices]利用assembly定义我们的组件在COM+中的注册方式
出处  
整理者 郑昀@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


    }

}

相关文章
对该文的评论