如何解决在ASP.NET 5 CS0433错误? [英] How do I fix CS0433 errors in ASP.NET 5?

查看:341
本文介绍了如何解决在ASP.NET 5 CS0433错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

的代码行,导致它的任何地方引用类型 System.Collections.Generic.Dictionary 无论是作为一个变量类型,或使用宣言

The line of code that causes it any place referencing type System.Collections.Generic.Dictionary whether as a variable type, or in a Using Declaration.

这使用申报工作得很好,使我的班比有少写恶心 System.Collections.Generic.Dictionary<字符串对象> 在我100级的地方。 ,采取使用声明了不解决我的问题,只是它移动到字典类型在我的方法的参数使用的地方

This Using declaration worked fine and made my classes less disgusting than having to write System.Collections.Generic.Dictionary<string, object> in 100 places in my class. Taking the Using declarations out does not solve my problem, it just moves it to the places where the dictionary type is used in my method parameters.

完整的错误文本:

CS0433  The type 'Dictionary<TKey, TValue>' exists in both
'System.Collections, Version=4.0.10.0, Culture=neutral,
  PublicKeyToken=b03f5f7f11d50a3a' 
 and 
'mscorlib, Version=4.0.0.0, Culture=neutral, 
 PublicKeyToken=b77a5c561934e089'   ProjectName.DNX 

在ASP.NET MVC 5使用DNX 1.0.0-同β7基于6模板项目出现此错误,有一些型号和引用泛型集合类型的控制器类。该project.json因此设置:

This error occurs in ASP.NET 5 MVC 6 template based projects using DNX 1.0.0-beta7, having some Model and Controller classes that reference generic collection types. The project.json is set thus:

  "frameworks": {
    "dnx451": { }
  }

时的样本问题:

  "frameworks": {
    "dotnet": { }
  }




  • 代码,导致它是一个使用声明,各种各样的类型的别名,这工作得很好,直到我设法线一个beta6项目转换为同β7。

    • The line of code that causes it is a Using declaration, a type alias of sorts, that worked fine until I try to convert a beta6 project to beta7.

      转换进行,直到我尝试添加这些使用JsonDictionary别名,然后编译休息。

      Conversion proceeds until I try to add these using JsonDictionary aliases, then compilation breaks.

      我已经搜索该错误代码,它有着悠久的历史不光彩ASP.NET中。

      I have searched this error code and it has a long and Inglorious history in ASP.NET.

      是什么原因导致这个问题?我怎么能解决这个问题,因为我无法从我的项目中移除mscorlib程序,我也不能System.Collections中删除?

      What causes this problem? And how can I fix it, since I can't remove mscorlib from my project, nor can I remove System.Collections?

      推荐答案

      在当你创建一个类库项目它会设置的框架部分,您张贴着DOTNET
      ,但如果你在同β7创建一个新的类库项目,将其设置这样的方式beta6:

      In beta6 when you created a class library project it would setup the frameworks section the way you posted with "dotnet" but if you create a new class library project in beta7 it will set it up like this:

      "frameworks": {
          "dnx451": { },
          "dnxcore50": {
            "dependencies": {
              "Microsoft.CSharp": "4.0.1-beta-23225",
              "System.Collections": "4.0.11-beta-23225",
              "System.Linq": "4.0.1-beta-23225",
              "System.Runtime": "4.0.21-beta-23225",
              "System.Threading": "4.0.11-beta-23225"
            }
          }
        }
      

      我相信如果你更新你的项目的JSON因此它会解决这个问题。

      I believe that if you update your project json accordingly it will solve the problem.

      这篇关于如何解决在ASP.NET 5 CS0433错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆