[MonoDevelop] [NonSerialized] causes property to be null.
David Nelson
eatdrinksleepcode at gmail.com
Wed Sep 4 21:24:10 UTC 2013
Unfortunately this is expected (though unintuitive and hacky-feeling) behavior. Field initializers are executed at the start of the constructor call; but serialization bypasses normal object construction.
See "Object Serialization in the .NET Framework" on MSDN from 2001.
On Sep 2, 2013, at 1:00 PM, Eric Hosick <erichosick at interfacevision.com> wrote:
> Hi all,
>
> Strange behavior just wanted to know if it is expected:
> [NonSerialized] private Hashtable p_wrappedInstance = new Hashtable();
>
> [XmlIgnore] public Hashtable wrappedInstance {
> get {
> if ( null == p_wrappedInstance ) {
> Console.WriteLine ("This only shows when p_wrappedInstance is marked as [NonSeralized].");
> }
> return p_wrappedInstance;
> }
> set {
> if ( null == value ) {
> Console.WriteLine ("This is never seen in console.");
> }
> p_wrappedInstance = value;
> }
> }
>
> I've removed the [NonSerialized] attribute and things work fine. Just want to know if this is expected behavior.
>
> Regards,
>
> Eric
> _______________________________________________
> Monodevelop-list mailing list
> Monodevelop-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/monodevelop-list
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ximian.com/pipermail/monodevelop-list/attachments/20130904/b0cf33d9/attachment.html>
More information about the Monodevelop-list
mailing list