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

笑着哭i 提交于 2019-12-08 05:34:02

问题


I try use .net core but I have a lot of diffrent problems. This is one of them. I use Ubuntu 14.

Error code

    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 

I tried different methods but none helped me.

This is my project.json file

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

Any body can help me?


My new working 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-*"
            } 
        }
    } 
}

回答1:


Try moving System.Xml.XmlSerializer to the dnxcore50 dependencies. dnx451 already has the XmlSerializer class, so it doesn't need the System.Xml.XmlSerializer package (which depends on the System.Collections package)



来源:https://stackoverflow.com/questions/31907796/cs0433-the-type-listt-exists-in-both

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