添加类型:无法添加类型。找不到程序集'System.IO.Compression.FileSystem' [英] Add-Type: Cannot add type. The assembly 'System.IO.Compression.FileSystem' could not be found

查看:568
本文介绍了添加类型:无法添加类型。找不到程序集'System.IO.Compression.FileSystem'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在TeamCity构建中使用简单的PowerShell脚本。

I am using simple PowerShell script in TeamCity Builds.

它需要 System.IO.Compression.FileSystem ,并且代理已安装.NET 4.5.2。以下是已安装的.NET框架

It requires System.IO.Compression.FileSystem and the agent has .NET 4.5.2 installed. Below are the .NET frameworks installed

PSChildName         Version             Release             Product            
-----------         -------             -------             -------            
v2.0.50727          2.0.50727.5420                                             
v3.0                3.0.30729.5420                                             
Windows Communic... 3.0.4506.5420                                              
Windows Presenta... 3.0.6920.5011                                              
v3.5                3.5.30729.5420                                             
Client              4.5.51209           379893              4.5.2              
Full                4.5.51209           379893              4.5.2              
Client              4.0.0.0                                    

PowerShell脚本具有以下行

The PowerShell script has following line

[Reflection.Assembly]::LoadWithPartialName("System.IO.Compression.FileSystem");
Add-Type -AssemblyName System.IO.Compression.FileSystem

在第二行上,执行失败并出现错误

On the second line, the execution fails with error

Add-Type : Cannot add type. The assembly 'System.IO.Compression.FileSystem' could not be found.
At C:\BuildAgent\someFile.ps1:104 char:13
+     Add-Type <<<<  -AssemblyName System.IO.Compression.FileSystem
+ CategoryInfo          : ObjectNotFound: (System.IO.Compression.FileSystem:String) [Add-Type], Exception
+ FullyQualifiedErrorId : ASSEMBLY_NOT_FOUND,Microsoft.PowerShell.Commands.AddTypeCommand

很奇怪,但是我希望使用 .NET 4.5.2 ,PowerShell应该能够从 GAC

Strange, but I expected that with .NET 4.5.2, PowerShell should be able to load assembly from GAC

加载程序集。 / p>

Any help will be appreciated

推荐答案

尝试改为加载特定的DLL:

Try to load particular DLL instead:

Add-Type -Path C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.IO.Compression.FileSystem\v4.0_4.0.0.0__b77a5c561934e089\System.IO.Compression.FileSystem.dll

这篇关于添加类型:无法添加类型。找不到程序集'System.IO.Compression.FileSystem'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆