C# – Upgrade to .Net 4.5 causes assembly to fail

cnetvisual studio 2012

I've got a project that targets .Net 4.0, and one of the referenced assemblies is .Net 4.5.

Until I installed .Net 4.5 this was working fine, however after the install I get five warnings regarding the targeted .Net version along these lines:

*The primary reference "xxxx.Library, Version=1.0.0.1, Culture=neutral, processorArchitecture=MSIL" could not be resolved
because it was built against the ".NETFramework,Version=v4.5"
framework. This is a higher version than the currently targeted
framework ".NETFramework,Version=v4.0"

And this:

The primary reference "Microsoft.TeamFoundation.Build.Workflow, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a,
processorArchitecture=MSIL" could not be resolved because it has an
indirect dependency on the framework assembly "System.IO.Compression,
Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
which could not be resolved in the currently targeted framework.
".NETFramework,Version=v4.0". To resolve this problem, either remove
the reference "Microsoft.TeamFoundation.Build.Workflow,
Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a,
processorArchitecture=MSIL" or retarget your application to a
framework version which contains "System.IO.Compression,
Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089". Tests

Why does Visual Studio hate me? If it could compile before the update to 4.5, the targeted framework has not changed and it still works for a colleague on VS2010 with .Net 4 why am I being stuffed?

Best Answer

The error message explains the problem - a .NET 4 app can't reference a .NET 4.5 dll. Change your app to .NET 4.5 as well, or change the dll back to .NET 4.

Related Topic