当前位置:编程学习 > C#/ASP.NET >>

C# 程序集安装与卸载

下面我们来实现程序集的安装,代码如下:


/// <summary>
/// 程序集安装与卸载
/// </summary>
/// <param name="assemblyPath">程序集路径</param>
/// <param name="isInstall">是否安装(若为False则为卸载)</param>
public void AssemblyInstall(string assemblyPath, bool isInstall) {
System.Configuration.Install.TransactedInstaller transactedInstaller = new System.Configuration.Install.TransactedInstaller();
System.Configuration.Install.AssemblyInstaller assemblyInstaller = new System.Configuration.Install.AssemblyInstaller(assemblyPath, null);
transactedInstaller.Installers.Add(assemblyInstaller);
if (isInstall)
transactedInstaller.Install(null);
else
transactedInstaller.Uninstall(null);
}
    
补充:软件开发 , C# ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,