COM+学习体会(一)

博客介绍了COM+的使用,指出虽引用简单,但选合适服务需了解COM知识。分享第一小程序调试经验,如程序集要有强名称、使用COM+的类须为Public。还介绍了COM+导出的两种方式,以及COM+ Catalog编程实现和简单企业服务安装模式。

COM+的东西虽然用起来简单了一些,只要引用就可以,但实际上,如果想真正合适的一个引用的服务并不是很容易的,还是需要了解COM的知识的,COM世界博大精深,需要好好努力了!

写了第一小程序,调试经验如下:
1、程序集必须有一个强名称。
2、使用COM+的类必须是Public的,如果是私有的,将不能使用COM+服务。

导出COM+的两种方式:
1、Server Application:导出组件以及其配置,并配置到另一台机器上。以*.MSI的格式,生成Install文件。(使用于从开发的机器转移到使用的机器上。)
2、Client Proxy:仅仅导出代理,可以使其在另一台机器远程使用本机的服务。(并不是真正的导出组件)

COM+ Catalog编程实现:

Com+ Admin Library用于负责编程实现COM+ Catalog的功能。

简单的企业服务安装模式:
System.EnterpriseServices.RegistrationHelper接口也可以提供简单的COM+注册服务。当然功能少很多。
简单看了一下,主要提供初始化一个组件,Install,以及deInstall

一个最简单的程序:

None.gifnamespace ER
ExpandedBlockStart.gifContractedBlock.gif
dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif    
/**//// <summary>
InBlock.gif    
/// Class1 的摘要说明。
ExpandedSubBlockEnd.gif    
/// </summary>

InBlock.gif    public class  Register
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif        
private string path=@"c:\COMTest.dll";
InBlock.gif        
private string appId;
InBlock.gif        
private string typeId;
InBlock.gif        
public  Register()
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
ExpandedSubBlockEnd.gif        }

InBlock.gif        
public void Install()
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            System.EnterpriseServices.RegistrationHelper rh
=new RegistrationHelper ();
InBlock.gif              rh.InstallAssembly (path,
ref appId,ref  typeId,System.EnterpriseServices.InstallationFlags.Install);
ExpandedSubBlockEnd.gif         }

ExpandedSubBlockEnd.gif    }

ExpandedBlockEnd.gif}

None.gif


以下是其测试代码:
使用了NUNIT2.2


None.gifusing System;
None.gif
using NUnit.Framework;
None.gif
None.gif
namespace ER
ExpandedBlockStart.gifContractedBlock.gif
dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif    
/**//// <summary>
InBlock.gif    
/// TestRegister 的摘要说明。
ExpandedSubBlockEnd.gif    
/// </summary>

InBlock.gif    [TestFixture]
InBlock.gif    
public class TestRegister
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif        
public TestRegister()
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif 
ExpandedSubBlockEnd.gif        }

InBlock.gif        [Test]
InBlock.gif        
public void test()
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            Register registerObj
=new Register ();
InBlock.gif            registerObj.Install();
ExpandedSubBlockEnd.gif        }

ExpandedSubBlockEnd.gif    }

ExpandedBlockEnd.gif}


转载于:https://www.cnblogs.com/bluepiaoling/archive/2005/04/13/136885.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值