0

I recently had to convert a project from .net 4.5 to .net 4.0, which I thought would have been fine as I did not use anything that only 4.5 offered. However whenever I try to build my project I get an error message stating it's unable to find System.IO.Compression. I'm not quite sure why, my project doesn't work with compressed files and I haven't referenced it anywhere.

Why am I getting this error?

The error message:

Error   1   Could not load file or assembly 'System.IO.Compression, 
Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' 
or one of its dependencies. The system cannot find the file specified.  

More information: The whole solution is a silverlight application that I embed in an .aspx page. The error tells me that the silverlight application is unable to find the assembly, and I know silverlight doesn't have a System.IO.Compression

user2084666
  • 831
  • 3
  • 9
  • 14
  • 1
    I assume you've checked all of your `using` declarations and project references. – Robert Harvey Jul 25 '13 at 17:03
  • 1
    There is no System.IO.Compression in Silverlight. There's also no .NET 4.5 for Silverlight. So I'm confused by your question. – Tim Jul 25 '13 at 17:07
  • Yeah, I know. The Silverlight application didn't change at all, however the error I am receiving keeps telling me that it's inside the silverlight project. – user2084666 Jul 25 '13 at 17:16
  • Are you getting this error at runtime or compile time? - edit: n/m I see its during Build now. – Tim Jul 25 '13 at 17:16
  • Can we assume that when you compiled it as .NET 4 before converting, you didn't get this error? – Tim Jul 25 '13 at 17:21

2 Answers2

0

Either you're referencing System.IO.Compression or something that you're referencing references it (somewhere down the line). It has to be one of those two.

Tim
  • 14,999
  • 1
  • 45
  • 68
0

If you want to cut out all references that your project doesn't use, open each .cs file and do the following:

  • Right click at the using part of the file
  • Select Organize Using > Remove and sort

Then, right click on your solution, click Clean, wait for it, rebuilt your project again

Assume that you're using Visual Studio

Tuan Tran
  • 73
  • 6