locked
Decorating Class for use as value in Exception.Data RRS feed

  • Question

  • Have a class that I use to capture diagnostic information when throwing an exception.  I'm trying to add instances of the class to the Exception.Data dictionary as the value (the key being a typical string).  Exception.Data is complaining the class is not serializable.  Okay, fine.  But I can't find any options under Windows Store Apps to decorate the class as serializable.  Is there a pattern for this?

    -- kburgoyne

    Saturday, August 24, 2013 12:40 AM

Answers

  • Hi kburgoyne ,

    Welcome back!

    Thank you very much for your advice, we need your feedback, and we will improve and perfect our products if some developers expose this as what they are searching for.

    This thread is a long time ago, and if my reply is helpful, please mark it as answer, so i could close it.

    If you have any question other, please feel free let me know.

    Thanks for your understanding!

    Best Regards!


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    • Marked as answer by kburgoyne Friday, August 30, 2013 4:36 AM
    Friday, August 30, 2013 1:30 AM
    Moderator

All replies

  • Hi kburgoyne ,

    Welcome to MSDN forum!

    No, there is no pattern for this. Please have a try as shown below:

    http://msdn.microsoft.com/en-us/library/system.xml.serialization.xmlserializer.aspx?cs-save-lang=1&cs-lang=csharp#code-snippet-8

    Best Regards!

    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.


    Monday, August 26, 2013 5:25 AM
    Moderator
  • Sorry about the delay.  I had a major portion of the application gutted and being rebuilt.  I had to complete that before getting back to this issue.

    I copied the following decoration from your link "as is" just to see if Exception.Data["Key"] = MyObject would work.  Still throws an exception complaining that MyObject is not serializable.

    [XmlRootAttribute("PurchaseOrder", Namespace="http://www.cpandl.com", 
    IsNullable = false)]
    

    [Serializable] does not appear to be an option for Windows Store Apps.  This seem VERY strange to be missing.  It hints that the Microsoft developers had something else in mind to use instead.  It would be good to find a solution if possible since there would seem to be a wider application for the solution than just Exception.Data.


    -- kburgoyne

    Thursday, August 29, 2013 6:50 PM
  • Hi kburgoyne ,

    Welcome back!

    Thank you very much for your advice, we need your feedback, and we will improve and perfect our products if some developers expose this as what they are searching for.

    This thread is a long time ago, and if my reply is helpful, please mark it as answer, so i could close it.

    If you have any question other, please feel free let me know.

    Thanks for your understanding!

    Best Regards!


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    • Marked as answer by kburgoyne Friday, August 30, 2013 4:36 AM
    Friday, August 30, 2013 1:30 AM
    Moderator