c# - CS0433 : The type 'List<T>' exists in both

标签 c# dnx .net-core coreclr

我尝试使用.net core,但遇到了很多不同的问题。这是其中之一。我使用 Ubuntu 14。

错误代码

    Microsoft.Dnx.Compilation.CSharp.RoslynCompilationException: /home/lukasz/Project/Commands.cs(10,16): DNX,Version=v4.5.1 error CS0433: The type 'List<T>' 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'
/home/lukasz/Project/Commands.cs(10,21): DNX,Version=v4.5.1 error CS0433: The type 'List<T>' 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'
/home/lukasz/Project/DataManager.cs(16,17): DNX,Version=v4.5.1 error CS0433: The type 'List<T>' 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'
/home/lukasz/Project/DataManager.cs(16,22): DNX,Version=v4.5.1 error CS0433: The type 'List<T>' 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'
/home/lukasz/Project/DataManager.cs(17,17): DNX,Version=v4.5.1 error CS0433: The type 'List<T>' 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'
/home/lukasz/Project/DataManager.cs(18,17): DNX,Version=v4.5.1 error CS0433: The type 'List<T>' 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'
/home/lukasz/Project/DataManager.cs(25,28): DNX,Version=v4.5.1 error CS0433: The type 'List<T>' 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'
/home/lukasz/Project/DataManager.cs(25,33): DNX,Version=v4.5.1 error CS0433: The type 'List<T>' 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'
/home/lukasz/Project/Results/Participant.cs(128,16): DNX,Version=v4.5.1 error CS0433: The type 'List<T>' 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'
/home/lukasz/Project/Results/Participant.cs(133,40): DNX,Version=v4.5.1 error CS0433: The type 'List<T>' 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'
/home/lukasz/Project/Results/Participant.cs(14,17): DNX,Version=v4.5.1 error CS0433: The type 'List<T>' 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'
/home/lukasz/Project/Results/SessionResult.cs(23,16): DNX,Version=v4.5.1 error CS0433: The type 'List<T>' 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'
/home/lukasz/Project/Results/SessionResult.cs(28,41): DNX,Version=v4.5.1 error CS0433: The type 'List<T>' 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'
/home/lukasz/Project/Results/SessionResult.cs(9,17): DNX,Version=v4.5.1 error CS0433: The type 'List<T>' 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'
/home/lukasz/Project/Commands.cs(18,33): DNX,Version=v4.5.1 error CS0433: The type 'List<T>' 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'
/home/lukasz/Project/Commands.cs(18,38): DNX,Version=v4.5.1 error CS0433: The type 'List<T>' 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'
/home/lukasz/Project/Commands.cs(29,34): DNX,Version=v4.5.1 warning CS0168: The variable 'e' is declared but never used
/home/lukasz/Project/DataManager.cs(29,29): DNX,Version=v4.5.1 error CS0433: The type 'List<T>' 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'
/home/lukasz/Project/DataManager.cs(46,29): DNX,Version=v4.5.1 error CS0433: The type 'List<T>' 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'
/home/lukasz/Project/DataManager.cs(83,29): DNX,Version=v4.5.1 error CS0433: The type 'List<T>' 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'
/home/lukasz/Project/DataManager.cs(83,71): DNX,Version=v4.5.1 error CS0433: The type 'List<T>' 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'
/home/lukasz/Project/DataManager.cs(97,48): DNX,Version=v4.5.1 error CS0012: The type 'Type' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
/home/lukasz/Project/DataManager.cs(98,28): DNX,Version=v4.5.1 error CS0012: The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
/home/lukasz/Project/DataManager.cs(98,17): DNX,Version=v4.5.1 error CS0012: The type 'Stream' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.IO, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
/home/lukasz/Project/DataManager.cs(98,17): DNX,Version=v4.5.1 error CS0012: The type 'TextWriter' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.IO, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
/home/lukasz/Project/DataManager.cs(98,38): DNX,Version=v4.5.1 error CS1503: Argument 1: cannot convert from 'System.IO.MemoryStream' to 'System.Xml.XmlWriter'
/home/lukasz/Project/DataManager.cs(161,36): DNX,Version=v4.5.1 error CS0433: The type 'List<T>' 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'
/home/lukasz/Project/DataManager.cs(165,17): DNX,Version=v4.5.1 error CS0433: The type 'List<T>' 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'
/home/lukasz/Project/DataManager.cs(241,42): DNX,Version=v4.5.1 error CS0012: The type 'Type' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
/home/lukasz/Project/DataManager.cs(243,17): DNX,Version=v4.5.1 error CS0246: The type or namespace name 'XmlTextWriter' could not be found (are you missing a using directive or an assembly reference?)
/home/lukasz/Project/DataManager.cs(243,43): DNX,Version=v4.5.1 error CS0246: The type or namespace name 'XmlTextWriter' could not be found (are you missing a using directive or an assembly reference?)
/home/lukasz/Project/DataManager.cs(243,61): DNX,Version=v4.5.1 error CS0433: The type 'Encoding' exists in both 'System.Text.Encoding, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' and 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
/home/lukasz/Project/DataManager.cs(245,29): DNX,Version=v4.5.1 error CS0012: The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
/home/lukasz/Project/DataManager.cs(245,24): DNX,Version=v4.5.1 error CS0012: The type 'Stream' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.IO, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
/home/lukasz/Project/DataManager.cs(245,24): DNX,Version=v4.5.1 error CS0012: The type 'TextReader' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.IO, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
/home/lukasz/Project/DataManager.cs(245,41): DNX,Version=v4.5.1 error CS1503: Argument 1: cannot convert from 'System.IO.MemoryStream' to 'System.Xml.XmlReader'
/home/lukasz/Project/Results/Participant.cs(27,35): DNX,Version=v4.5.1 error CS0433: The type 'List<T>' 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'
  at Microsoft.Dnx.ApplicationHost.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <filename unknown>:0 
  at Microsoft.Dnx.Runtime.Common.EntryPointExecutor.Execute (System.Reflection.Assembly assembly, System.String[] args, IServiceProvider serviceProvider) [0x00000] in <filename unknown>:0 
  at Microsoft.Dnx.Host.Bootstrapper.RunAsync (System.Collections.Generic.List`1 args, IRuntimeEnvironment env, System.Runtime.Versioning.FrameworkName targetFramework) [0x00000] in <filename unknown>:0 

我尝试了不同的方法,但没有一个对我有帮助。

这是我的project.json 文件

{
    "version": "1.0.0-*",
    "dependencies":
    {
        "System.Xml.XmlSerializer": "4.0.10-beta-*"
    },
    "frameworks":
    {
        "dnx451":
        {
            "dependencies":{}
        },
        "dnxcore50":
        {
            "dependencies":
            {
                "System.Console": "4.0.0-beta-*"
            }
        }
    }
}

有人可以帮助我吗?


我的新工作project.json

{ 
    "version": "1.0.0-*", 
    "dependencies": 
    { 

    }, 
    "frameworks" : 
    { 
        "dnx451" : 
        {
            "frameworkAssemblies": 
            {
                    "System.Xml": "4.0.0.0"
            }
        }, 
        "dnxcore50" : 
        { 
            "dependencies": 
            { 
                "System.Console": "4.0.0-beta-*",
                "System.Xml.XmlSerializer": "4.0.10-beta-*"
            } 
        }
    } 
}

最佳答案

尝试将 System.Xml.XmlSerializer 移动到 dnxcore50 依赖项。 dnx451 已经具有 XmlSerializer 类,因此它不需要 System.Xml.XmlSerializer 包(这取决于 System.Collections 包) )

关于c# - CS0433 : The type 'List<T>' exists in both,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31907796/

相关文章:

c# - 如何简化设置对象多个属性的 C# 代码?

ASP.NET 5 DNX : How to shutdown application properly?

c# - 如何使用 AWSSDK.AppSync .net Core NuGet 包执行突变和查询数据?

c# 当子 pictureBox 更改 Image 时调整父控件的大小

c# - 实现集合的简单方法?

c# - Resharper:IEnumerable 的可能多重枚举

c# - 如何指向 .NET Core PCL 中的不同 project.json 位置?

c# - dnx 不加载正确的 .Net 库

c# - 在 Asp.Net Core 3.0 中禁用身份验证以进行开发

c# - 我如何在 jenkins 中使用 xunit (.net core) 测试结果?