【问题标题】:Deploy multiple dll files into gac without gacutil在没有 gacutil 的情况下将多个 dll 文件部署到 gac 中
【发布时间】:2014-07-25 15:41:33
【问题描述】:

所以,问题是我有几个 C# dll 需要部署到多台机器上的 gac 中。这些 没有gacutil,如果它保持这种状态,我会更喜欢。如何轻松部署这些文件,例如运行 exe 或批处理文件?是否有可能/好主意为 gac 部署创建一个可执行文件?如何做到这一点?

附言。我只有 ms visual studio express

【问题讨论】:

    标签: c# dll gac


    【解决方案1】:

    PowerShell 是你的朋友:

    function Gac-Util
    {
        param (
            [parameter(Mandatory = $true)][string] $assembly
        )
    
        try
        {
            $Error.Clear()
    
            [Reflection.Assembly]::LoadWithPartialName("System.EnterpriseServices") | Out-Null
            [System.EnterpriseServices.Internal.Publish] $publish = New-Object System.EnterpriseServices.Internal.Publish
    
            if (!(Test-Path $assembly -type Leaf) ) 
                { throw "The assembly $assembly does not exist" }
    
            if ([System.Reflection.Assembly]::LoadFile($assembly).GetName().GetPublicKey().Length -eq 0 ) 
                { throw "The assembly $assembly must be strongly signed" }
    
            $publish.GacInstall($assembly)
    
            Write-Host "`t`t$($MyInvocation.InvocationName): Assembly $assembly gacced"
        }
    
        catch
        {
            Write-Host "`t`t$($MyInvocation.InvocationName): $_"
        }
    }
    

    【讨论】:

      【解决方案2】:

      您的解决方案在程序集 System.EnterpriseServices.Internal 中

      那里已经回答了:C# how to register assembly in the GAC without GacUtil?

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多