15

I just have set up a new asp.net mvc 4 project, using the latest .net framework (4.5) in combination with Visual studio 2012. After I added some classes, side projects etc. I suddently notice that I'm receiving 5 times the same warning when I compile the project. The warning states:

ASPNETCOMPILER : warning CS1685: The predefined type 'System.Threading.Tasks.Task' is defined in multiple assemblies in the global alias; using definition from 'c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5\mscorlib.dll'

So now I'm wondering in which assemblies are this type defined than? All my projects in the solution are using version 4.5 of the .net framework, so 4.5\mscorlib.dll should be the only one or am I missing something?

My solutions consists of 4 projects ( 3 class libraries, and 1 mvc-4 web project). The 3 class libraries don't show any warnings when I compile them indepently. It's only the web project which throws the warnings, but the class library projects are referenced by the web project. The references of the web project:

  • Antlr3.Runtime
  • Microsoft.CSharp
  • Microsoft.Web.Infrastructure
  • System
  • System.Data
  • System.Web.DynamicData
  • System.Web.Entity
  • System.Web.ApplicationServices
  • System.ComponentModel.DataAnnotations
  • System.Core
  • System.Data.DataSetExtensions
  • System.Web.Optimization
  • System.Xml.Linq
  • System.Web
  • System.Web.Extensions
  • System.Web.Abstractions
  • System.Web.Routing
  • System.Xml
  • System.Configuration
  • System.Web.Services
  • System.EnterpriseServices
  • Newtonsoft.Json
  • System.Net.Http
  • System.Net.Http.Formatting
  • System.Net.Http.WebRequest
  • System.Web.Helpers
  • System.Web.Http
  • System.Web.Http.WebHost
  • System.Web.Mvc
  • System.Web.Razor
  • System.Web.WebPages
  • System.Web.WebPages.Deploymen
  • System.Web.WebPages.Razor
  • WebGrease

Does anyone have a suggestion where to look?

Thanks in advance

BHD

UPDATE It seems that more people have similar issues like this, in my case the answer was: We are using here some company libraries, which were indeed using older versions of the framework (3.5) and caused the warnings.

4
  • Has the computer where this happens, earlier had other versions of .NET 4.5 or .NET 4.0 installed? Mar 20, 2013 at 12:16
  • 2
    Your message doesn't specify what the other assembly is. Try, inside the same project that gives you the CS1685 warning, to introduce this variable: global::System.Threading.Tasks.Task test = null;. It should give you another error, like error CS0433: The type 't' exists in both 'x' and 'y' where x and y are the two assemblies in question. Mar 20, 2013 at 12:41
  • Good thinking Jeppe, I tried it, but no luck. Still the warnings, no error. May 7, 2013 at 8:23
  • 1

2 Answers 2

8

Similar to article C# Compiler Warning 1685. Check if any of the referenced assemblies are themselves referencing different versions of mscorlib.dll.

Get hold of DotPeek or .NET Reflector and you should be able check what versions of assemblies the referenced assemblies are referencing.

5
  • 1
    I agree. Specifically check if Antlr3.Runtime, Newtonsoft.Json, or WebGrease refer other versions of mscorlib.dll, for example some .NET 4.0 version. Maybe look at version numbers in the project file? Mar 20, 2013 at 12:27
  • That is in the end where it comes down to. But since this is a new/clean project I was wondering which mvc dependency is responsible for this. I just have installed reflector, how can I check the dependencies of my dependencies? May 7, 2013 at 8:17
  • @BlackHawkDesign: If you get DotPeek, drop your assembly into the assembly explorer. You'll be able to see your dependencies and their versions. Double click each dependency to load it and examine it's dependencies.
    – Phil
    May 7, 2013 at 11:17
  • Thanks Phil, I found out that my companies libraries are indeed using older versions of the mscorlib.dll. When I find the time I will check if this causes the warning, but Im quite sure they do. May 14, 2013 at 7:59
  • Months later I found out that indeed my companies libraries were the cause, I finally replaced them and the warning vanished :) Thanks a lot @Jeppe: Yeah after removing the warnings, I received a new one caused by web crease, soo annoying! Nov 15, 2013 at 15:42
4

Visual Studio output can give you the details of which assemblies are triggering this. You will need the output to be at the "Detailed" level. Go to (in VS 2019 at least):

Tools -> Options -> Projects and Solutions -> Build and Run

and select "Detailed" for for "MSBuild project build output verbosity".

Then grab the build output and look for something like "There was a conflict between...". That should list out the referencing assemblies, and the versions of the assembly that is in conflict. That info should be enough to decide on a course of action.

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.