Install assembly to GAC with VS Installer

 

A useful tip from Mike Belshe on installing asssemblies into the GAC from code.

Combining that with an Installer class allows you to add that capability to your installation. Choose any of the libraries that you are deploying and add a new Installer class. Override the following two methods

public override void  Install(IDictionary stateSaver)
{
     base .Install (stateSaver);

     string  strAssemblyFile =  base .Context.Parameters["name"].ToString();
    System.EnterpriseServices.Internal.Publish foo =  new  System.EnterpriseServices.Internal.Publish();
    foo.GacInstall(strAssemblyFile);
}
    
public override void  Uninstall(IDictionary savedState)
{
     string  strAssemblyFile =  base .Context.Parameters["name"].ToString();
    System.EnterpriseServices.Internal.Publish foo =  new  System.EnterpriseServices.Internal.Publish();
    foo.GacRemove(strAssemblyFile);
            
     base .Uninstall (savedState);
}

Then in your installer project, open the "Custom Actions" and add a new action to the install and uninstall nodes, selecting the assembly that you added the installer class to.

Then you can install any other assembly that you are deploying to the GAC by passing it's name to the CustomActionData, and you can have as many custom actions as you need on the same assembly.

powered by IMHO 1.2

转自:http://dotnet.org.za/colin/archive/2005/05/10/19709.aspx

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值