The predefined type 'System.Threading.Tasks.Task' is defined in multiple assemblies in the global alias

旧城冷巷雨未停 提交于 2019-12-01 14:06:07

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/15408142/the-predefined-type-system-threading-tasks-task-is-defined-in-multiple-assembl

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!