Welcome Guest! To access all forums & features, please register an account or sign-in. → Why register?



[C#] Serialize problems


No replies to this topic - - - - -

#1 sathenzar

    Resident Fanatic

  • 873 posts
  • Joined: 12-June 06

Posted 28 March 2012 - 04:28

I am trying to serialize across a web service a dictionary and custom classes. I can do this fine with one problem for each method. For serialize dictionary it can't contain an empty dictionary or it'll crash (which is really freaking annoying). Here is the code I have for serializing a dictionary:
Problem solved

So I'd love to fix that problem. The second problem is with custom classes I can't serialize public get/private setter fields (which is also really annoying). I tried the method of declaring private fields globally and that worked for 5 builds then all of the sudden the web service said hey! your code that's worked for 5 builds isn't working anymore! You MUST make all of your fields insecure and writable! Is .NET seriously unable to account for public get fields with private setters? That'd be just a terrible design. Please help :)

EDIT: I figured out the first problem. I have to pass the value as null instead of an empty dictionary. The first problem is still an issue though.