Dave
Dave

Reputation: 316

Upgrade to .Net 4.5 causes assembly to fail?

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?

Upvotes: 13

Views: 10410

Answers (2)

Reg Edit
Reg Edit

Reputation: 6924

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.

Upvotes: 5

thecoop
thecoop

Reputation: 46158

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.

Upvotes: 13

Related Questions