Why won't my .NET 4.0 builder be installed in the GAC using Powershell?

I am using the .ps1 script to register the .NET 4.0 assembly set in the GAC on the Win 2008 R2 release server. Nodes have strong names, and the script does not return errors :

[Reflection.Assembly]::LoadWithPartialName("System.EnterpriseServices");
[System.EnterpriseServices.Internal.Publish] $publish = New-Object System.EnterpriseServices.Internal.Publish;

$publish.GacInstall("D:\MyComponents\EZTrac.Domain.Dealer.dll")

After starting, I look at GAC_MSIL (where it should be) and then GAC_32 and GAC_64 for a good grade, but it’s not in any of them.

I used this post as a guide. Any idea what I forget here?

+4
source share
3 answers

. , v2 PowerShell .NET 4.0. WMF 3 WMF 4, Powershell 3 4.

+1

, gaccing. , :

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): $_"
    }
}
+5

: System.EnterpriseServices.Internal.Publish .Net 2.0 .Net 4.0 - . PowerShell v3 PowerShell .Net 4.0 - . .

Other alternatives use .Net 4.0 gacutil or look at my PowerShell GAC module , which is able to install .Net 4.0 assemblies in PowerShell v2 and gives errors if something goes wrong.

0
source

All Articles