PowerShellを使用してzipファイルを抽出します。したがって、私はこれを使用します:Load System.IO.Compression.FileSystem with Add-Type throwsエラー
Add-Type -AssemblyName System.IO.Compression.FileSystem
# some code to download the zip file from FTP #
[System.IO.Compression.ZipFile]::ExtractToDirectory($localpath+"\Test.zip",$localpath)
私はエラーが発生します:Add-Type:タイプを追加できません。アセンブリ 'System.IO.Compression.FileSystem'が見つかりませんでした。
私は、その後のStackOverflowを検索し
Add-Type -Path "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\System.IO.Compression.FileSystem.dll"
に
Add-Type -AssemblyName System.IO.Compression.FileSystem
を変更それは言う:
Error: Could not load file or assembly 'file:///C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFram
ework\v4.6.1\System.IO.Compression.FileSystem.dll' or one of its dependencies. This assembly is built by a runtime newer
than the currently loaded runtime and cannot be loaded.
私が実際にそのv4.6.1パスにこのDLLを見ることができます。それはそこにある。私の構文に何が間違っていますか?
もっと正確に言えば、Powershell V3は.NET 4.0のみをロードしますが、このタイプは.NET 4.5に含まれていますので、WMF4を使用する必要があります。 –
PS3.0に.Net 4.5を使用させることはできませんか? – sodawillow
いいえ。それは.NET 4.0でコンパイルされ、後で何も知らないでしょう。それが私が最新のPSとWMFにアップデートすることを提案した理由です。 –