none
[U8.1]How do I make a class serializable to use with a ValueSet

    Question

  • Hi,

    I'm trying to add an object in a Windows.Foundation.Collections.ValueSet and I got the error

    "Data of this type is not supported. (Exception from HRESULT: 0x8007065E)"

    The doc said that ValueSet prevents non-serializable types from being put into the map.

    The class I'm trying to add is marked with DataContract attribute but it does not work.

    In an Universal Windows App, is it possible to make a class serializable and put an object of that class in a ValueSet ?

    Thanks

    Frederic

    Thursday, July 09, 2015 4:58 PM

Answers

  • Hello Frederic,

    >>In an Universal Windows App, is it possible to make a class serializable and put an object of that class in a ValueSet ?

    For making a class serializable in windows runtime, it is what you did that by adding DataContract attribute, however, for adding a custom type to the ValueSet object, we need to make the class implement the IPropertySet as:

    public class TestClass: IPropertySet
    
    {
    ...
    }
    

    Then it could be added to the ValueSet object:

    ValueSet set = new ValueSet();
    
    TestClass tc = new TestClass();
    
    set.Add("1", tc);
    

    Regards.


    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.

    • Marked as answer by Fred Outlook Saturday, July 11, 2015 11:57 AM
    Friday, July 10, 2015 11:39 AM

All replies

  • Hello Frederic,

    >>In an Universal Windows App, is it possible to make a class serializable and put an object of that class in a ValueSet ?

    For making a class serializable in windows runtime, it is what you did that by adding DataContract attribute, however, for adding a custom type to the ValueSet object, we need to make the class implement the IPropertySet as:

    public class TestClass: IPropertySet
    
    {
    ...
    }
    

    Then it could be added to the ValueSet object:

    ValueSet set = new ValueSet();
    
    TestClass tc = new TestClass();
    
    set.Add("1", tc);
    

    Regards.


    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.

    • Marked as answer by Fred Outlook Saturday, July 11, 2015 11:57 AM
    Friday, July 10, 2015 11:39 AM
  • Hello Fred,

    Thank you for the information and the clear explanation.

    Frederic

    Saturday, July 11, 2015 11:57 AM