Loading assembly via reflection succeeds, Add-Type does not


I'm using a .net assembly in Powershell. This code works successfully:

$marketMetadataRepository = New-Object dh.Common.Metadata.MarketMetadataRepository


GAC Version Location

--- ------- -------- False v4.0.30319

So one would think this would work successfully also:

Add-Type -AssemblyName

but no:

Add-Type : Could not load file or assembly 'E:\Workspaces\RTE\dh.PSP.Common\Mainline\Source\dh.Common.MetaData\bin\dh.Common.Metadata.dll' or one of its dependencies. The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047)

I'm confused as to why one method would work and another does not. Any ideas?

asked on Stack Overflow Dec 10, 2014 by jamiet

1 Answer


The -assemblyname parameter of Add-Type expects an full or partial assembly name. Try using -path instead.

answered on Stack Overflow Dec 10, 2014 by Martin

User contributions licensed under CC BY-SA 3.0