开发者

XmlSerializerNamespaces is ambiguous in the namespace System.Xml.Serialization?

开发者 https://www.devze.com 2023-01-25 00:50 出处:网络
Anyone ever seen this error?It\'s happening seemingly out of nowhere in a .net 3.5 Web app project that instantiates this namespaces object for use in xml serialization.I have cleaned and tried to reb

Anyone ever seen this error? It's happening seemingly out of nowhere in a .net 3.5 Web app project that instantiates this namespaces object for use in xml serialization. I have cleaned and tried to rebuild the solution, checked and reset references to System.Xml. This is in code that has not been touched in over a yea开发者_开发问答r. The project was recently upgraded to .net 3.5 but has been through at least two build cycles since the upgrade without issue. Any ideas?

Here is the guidance MS provides

Some code:

    Dim serializerNamespaces As New System.Xml.Serialization.XmlSerializerNamespaces()
    serializerNamespaces.Add("xsi", "http://www.w3.org/2001/XMLSchema-instance")


This issue came up again and thought I'd document it here for future reference. The cause was that SvcUtil.exe was used to generate a proxy for a WCF service call, and in doing so it created a partial class in the same .NET namespace that was being used in another class. In this case the partial class is not being used so just commented out the generated class and issue solved.

Namespace System.Xml.Serialization

<System.Diagnostics.DebuggerStepThroughAttribute(), _
 System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0"), _
 System.Runtime.Serialization.DataContractAttribute(Name:="XmlSerializerNamespaces", [Namespace]:="http://schemas.datacontract.org/2004/07/System.Xml.Serialization")> _
Public Class XmlSerializerNamespaces
    Inherits Object
    Implements System.Runtime.Serialization.IExtensibleDataObject

    Private extensionDataField As System.Runtime.Serialization.ExtensionDataObject

        Public Property ExtensionData() As System.Runtime.Serialization.ExtensionDataObject Implements System.Runtime.Serialization.IExtensibleDataObject.ExtensionData
            Get
                Return Me.extensionDataField
            End Get
            Set(ByVal value As System.Runtime.Serialization.ExtensionDataObject)
                Me.extensionDataField = value
            End Set
        End Property
    End Class
End Namespace


Have you tried fully qualifying the class name? What does the usage look like?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号