MVC3 Project doesn't build due to indirect dependency on different framework versions

86 views Asked by At

A project that used to build fine on my system (MVC3 .net 4.0) has stopped working since I installed .net 4.6.2. (this is on windows 10 with VS2017 Pro). I get a bunch of build errors about not being able to find types which if i click on in the error list to jump to the file location, the syntax highlighting shows that all is good. However i get some warnings that i think are the actual source of the error that read something like this

The primary reference "....Services.dll" could not be resolved because it has an indirect dependency on the framework assembly "System.Threading.Tasks, Version=1.5.11.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which could not be resolved in the currently targeted framework. ".NETFramework,Version=v4.0". To resolve this problem, either remove the reference "...Services.dll" or retarget your application to a framework version which contains "System.Threading.Tasks, Version=1.5.11.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".  

and then i have a second warning that looks like this

The primary reference "...Services.dll" could not be resolved because it has an indirect dependency on the framework assembly "System.Threading.Tasks, Version=2.6.9.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which could not be resolved in the currently targeted framework. ".NETFramework,Version=v4.0". To resolve this problem, either remove the reference "...Services.dll" or retarget your application to a framework version which contains "System.Threading.Tasks, Version=2.6.9.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".     

I'm confused as to why there are two different references to different version of the same assembly but more confused than ever as to why it fails to build and what these warning are telling and why installing the latest version of .NET has caused this.

UPDATE

So I through it would be a good idea to install Rider and it has the same problems. Logging at its diagnostic view it points out that the project is configured for build tools version 4.0 and only 15 is available. I shall try to download the MSbuild tools and see if that helps

1

There are 1 answers

1
ali On

I think your main problem is not the .NET version but the migration to newer version of MVC (similar issue in this post). VS 2017 does not support MVC 3 and you need to follow the migration steps properly which is mentioned here. I think the different versions of the same assembly result from faulty migration to MVC 5.