Search code examples
c#interfacedatacontractserializerinterface-implementation

DataObjectSerializer interface implementation CS0535


I am trying to make a class of my project serializable so I can exchange objects of it throgh a network for a client/server-application.

Since I also want to include "child"-objects and private members I chose to do so with the help of DataContractSerializer.

However, although I am layzily trying to copy-paste my first draft out of MSDN's respective site, do not get good results. I already referenced the System.Runtime.Serialization.dll as well as all the related namespaces.

Here's my issue: When trying to compile I get

CS0535 'Server.Anfrage' does not implement interface member 'System.Runtime.Serialization.IExtensibleDataObject.ExtensionData' (CS0535)

although I got my the specified member implemented. For now I am only trying to get it to work with the 3 strings, but later it's going to be more.

[DataContract]
public class Anfrage : IExtensibleDataObject
{

    [DataMember]
    internal string sender, aktion, param;


    internal halbAuftrag execute(){

        Bahnhof von = Program.bahnhoefe[Program.getIndex(sender)];
        Bahnhof zu = Program.bahnhoefe[Program.getIndex(param)];

        return new halbAuftrag(von, aktion, zu);
    }

    internal ExtensionDataObject extensionData_Value;

    public ExtensionDataObject extensionData {

        get {
            return extensionData_Value;
        }

        set {
            extensionData_Value = value;
        }
    }
[...]
}

Can anyone tell me why I am getting the aforementioned error? Thanks a lot.


Solution

  • You have a small typo. The following line

    public ExtensionDataObject extensionData {
    

    Should be

    public ExtensionDataObject ExtensionData {
    

    (capital E)