0

I am developing an application in windows phone 7 .I want to persist my object which contains private data members so as to restore my application after tomb stoning. Now the problem is

namespace xyz 
{
          [DataContract]
          public class ClassABC
          {

            [DataMember]
            private string a;

            [DataMember]
            private A b ; // A is a user defined class which is also serializable
          }
 }

now when I use

  ClassABC abc = new ClassABC();
  var axds= IsolatedStorage.ApplicationSettings;
  axdes["some key"] = abc ;
  IsolatedStorage.ApplicationSettings.save(); 

// this raised a security exception that ClassABC is not serializable because it is not public.

I don't know why is this problem occurring.

Please help.

rakesh
  • 602
  • 1
  • 5
  • 23
  • I have a class which has got data members which are internal to the class.Now I donnot want them to be made public – rakesh Feb 02 '12 at 13:18
  • See: http://stackoverflow.com/questions/4989532/type-is-not-serializable-because-its-not-public – David Spence Feb 02 '12 at 13:25

1 Answers1

0

I ran into the same problem with my app. Unfortunately WP7 cannot serialize non-public members due to the trust level. To get this to work I had to change my properties all to public and then my serialize/deserialize methods worked like a charm. I wish i had a better work around for someone who NEEDS to keep their properties private but I'm not aware of anything.

Dylan Hayes
  • 2,331
  • 1
  • 23
  • 33