Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/visual-studio/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# XmlInclude在Unii测试项目中_C#_Visual Studio_Unit Testing - Fatal编程技术网

C# XmlInclude在Unii测试项目中

C# XmlInclude在Unii测试项目中,c#,visual-studio,unit-testing,C#,Visual Studio,Unit Testing,我试图在单元测试中使用xmlclude(在VisualStudio测试项目中),我收到了奇怪的错误消息CS1729;'XmlIgnoreAttribute'不包含接受1个参数的构造函数。在非单元测试项目中,代码编译良好。有人知道为什么吗 [TestMethod] public void TestAndExplore() { Test x = new Test(); Serialization.SerializeToXmlString(x);

我试图在单元测试中使用
xmlclude
(在VisualStudio测试项目中),我收到了奇怪的错误消息
CS1729;'XmlIgnoreAttribute'不包含接受1个参数的构造函数
。在非单元测试项目中,代码编译良好。有人知道为什么吗

    [TestMethod]
    public void TestAndExplore()
    {
        Test x = new Test();
        Serialization.SerializeToXmlString(x);
    }

    public class Test : ModelBase { public Base Base { get; set; } = new Derived(); }

    [XmlInclude(typeof(Derived))]
    public class Base { }
    public class Derived : Base { }

这个问题与XmlInclude无关。您的代码中有XmlIgnoreAttribute,这是您在post.Hm中完成的。我有这样一句话:
[xmlclude(typeof(派生))]
那行有什么问题?没有。是的,但在单元测试项目中使用时,它会给出CS1729错误消息。您正在执行以下操作: