CS0433: тип «Список‹T›» существует в обоих

Я пытаюсь использовать .net core, но у меня много разных проблем. Это одна из них. Я использую Убунту 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-*"
            } 
        }
    } 
}

person assassin1909    schedule 09.08.2015    source источник


Ответы (1)


Попробуйте переместить System.Xml.XmlSerializer в зависимости от dnxcore50. dnx451 уже имеет класс XmlSerializer, поэтому ему не нужен пакет System.Xml.XmlSerializer (который зависит от пакета System.Collections)

person Thomas Levesque    schedule 09.08.2015
comment
Спасибо за помощь. Теперь это работает, но мне пришлось добавить System.Xml к frameworkAssemblies в dnx451. - person assassin1909; 10.08.2015