locked
DataContractSerializer and xsd classes RRS feed

  • Question

  • Hello everyone,

    I have this very devious class hierarchy that is supposed to be saved as an XML file. I found that the DataContractSerializer is quite suitable for this objects (or at least as suitable as the XAML servcies), so I went ahead and added the DataContract and DataMember attributes to all the items in the class hierarchy.

    Now, the problem is, one of the classes in this hierarcy references another class (which is outside), defined in an xsd file (created with visual studio editor). The class is a nested class (yup). The topmost class inherits from DataSet, the nested class inherits from DataRow. I couldn't find any way of adding the required attributes for the DataContractSerializer, as the designer will undo all my changes upon build (since the file is automatically generated).

    How can I serialize this class along with my other classes? Apparently, DataSet has a method that write XML directly, but i can't find a way to make it work with DataContractSerializer :(

    The application makes heavy use of datagridview and all teh related data controls. This is probably the reason why it uses a database and xsd in the first place (i am not the one who designed it btw). 


    • Edited by mcosmin Wednesday, May 13, 2015 8:50 AM
    • Moved by Youjun Tang Thursday, May 14, 2015 8:17 AM more related to the suggested forum
    Wednesday, May 13, 2015 8:43 AM

All replies

  • Hi mcosmin,

    This forum is discussing about Data controls and Databinding, your issue is more related with DataContractSerializer, I will move this thread to the more related forum.

    Reference: http://social.msdn.microsoft.com/Forums/en-US/home?forum=xmlandnetfx

    Thanks for your understanding.

    Best Regards,

    Edward


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, May 14, 2015 8:15 AM