1

I am writing a powershell script to run on a windows server 2008-r2 box running powershell v2, and it requires the ability to zip files. To do that, I need to have this line of code to import the assembly:

add-type -path "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\System.IO.Compression.FileSystem.dll" 

However, when I run the code, it errors with:

Add-Type : Could not load file or assembly 'file:///C:\Windows\Microsoft.NET\Framework64\v4.0.30319\System.IO.Compressi on.FileSystem.dll' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runt ime and cannot be loaded. 

So I went to check what .NET version is installed using the registry method provided here: Microsoft: How to determine which .NET Framework versions are installed

And sure enough I am on

378758 == .NET Framework 4.5.1 installed on Windows 8, Windows 7 SP1, or Windows Vista SP2 

And it even shows the install path as:

C:\Windows\Microsoft.NET\Framework64\v4.0.30319 

Does anyone know what may be the issue here? Or what I can do as a workaround (Without software updates/installs).

5
  • Try Add-Type -Assembly System.IO.Compression.FileSystem Commented May 2, 2017 at 12:08
  • I received this error: "Cannot add type. The assembly 'System.IO.Compression.FileSystem' could not be found." Commented May 2, 2017 at 12:13
  • Ok, try this path instead: Add-Type -Path "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.IO.Compression.FileSystem.dll" Commented May 2, 2017 at 12:25
  • That path does not exist on my server.. I don't have a 'Reference Assemblies' folder in program files (x86) Commented May 2, 2017 at 12:27
  • Possible duplicate of What does the ".NET Framework Version" setting in IIS actually do? Commented Oct 20, 2017 at 13:08

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.