13
votes

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?

2
I'm having a similar issue, and seems to only happen with .NET Frameworks 4.5 installed. My project is targeting frameworks version 4.0 and the disassembly of my referenced DLL shows the assembly was built targeting frameworks version 4.0 as well. However, I am getting an invalid error that the referenced DLL was built targeting version 4.5 of the frameworks. stackoverflow.com/questions/18360561/…Dude0001

2 Answers

13
votes

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.

5
votes

It's because for reasons best known to Microsoft, the .NET Framework 4.5 is an in-place update that replaces your .NET Framework 4 files (rather than a side-by-side installation). If you look in C:\Windows\Microsoft.NET, you won't find a 4.5 folder--it replaced the files in your 4.0 folder.

So the reason it compiled before is that the dll was a .Net 4.0 dll then. Now it's been replaced by a 4.5 one.