我正在编写一些使用
MSDeploy API的PowerShell脚本。我可以加载组件
原文链接:https://www.f2er.com/windows/372384.html[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.Web.Deployment")
位置在GAC:
PS > [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.Web.Deployment") | fl Location Location : C:\Windows\assembly\GAC_MSIL\Microsoft.Web.Deployment\7.1.0.0__31bf3856ad364e35\Microsoft.Web.Deployment.dll
但是,我无法使用Add-Type加载程序集。我收到一个错误,指出程序集无法找到,并且缺少一个或多个程序集。
PS > Add-Type -AssemblyName Microsoft.Web.Deployment Add-Type : Cannot add type. The assembly 'Microsoft.Web.Deployment' could not be found. At line:1 char:9 + Add-Type <<<< -AssemblyName Microsoft.Web.Deployment + CategoryInfo : ObjectNotFound: (Microsoft.Web.Deployment:String) [Add-Type],Exception + FullyQualifiedErrorId : ASSEMBLY_NOT_FOUND,Microsoft.PowerShell.Commands.AddTypeCommand Add-Type : Cannot add type. One or more required assemblies are missing. At line:1 char:9 + Add-Type <<<< -AssemblyName Microsoft.Web.Deployment + CategoryInfo : InvalidData: (:) [Add-Type],InvalidOperationException + FullyQualifiedErrorId : ASSEMBLY_LOAD_ERRORS,Microsoft.PowerShell.Commands.AddTypeCommand
如何使用Add-Type来加载Microsoft.Web.Deployment?