gpt4 book ai didi

c# - SGEN : The top XML element from namespace references distinct types

转载 作者:太空宇宙 更新时间:2023-11-03 14:25:07 27 4
gpt4 key购买 nike

我有以下类(都在同一个命名空间 Test.NamespaceTest 中定义):

[XmlRootAttribute("rootTag")]
public class BaseClass
{
}


[XmlRootAttribute("rootTag")]
public class MyClass : BaseClass
{
}

和类似的

[XmlRootAttribute("rootTag")]
public class Class1
{
}


[XmlRootAttribute("rootTag")]
public class Class2
{
}

当 sgen 尝试为这些类创建序列化程序集时,我收到以下错误(B​​aseClass 和 MyClass 也一样):

The top XML element 'rootTag' from namespace " references distinct types Test.NamespaceTest.Class1 and Test.NamespaceTest.Class2. Use XML attributes to specify another XML name or namespace for the element or types.

现在,这些类应该使用相同的根名称,所以我定义了 XmlRootAttribute。我需要做什么才能让 sgen 工作?这些类被序列化并作为 SOAP 请求发送到现有服务,因此如果我添加命名空间值,当服务尝试反序列化请求时,不会弄乱服务,因为最初没有定义命名空间吗?

最佳答案

这在添加一些命名空间属性后得到解决。

关于c# - SGEN : The top XML element from namespace references distinct types,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4315137/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com