Okay now this is getting interesting. I assumed that the warning was about the child class, but I&#39;m not sure. A bit of info: The parent C# class is called Object. I did&nbsp;the override&nbsp;on on&nbsp;__reduce_ex__ &nbsp;as&nbsp;you suggested but&nbsp;trying&nbsp;to pickle still produced&nbsp;the&nbsp;same error:&nbsp;<br>
<br>Type &#39;IronPython.NewTypes.Engine.Object_1$2&#39; in Assembly &#39;Snippets.scripting, Version=<a href="http://0.0.0.0">0.0.0.0</a>, Culture=neutral, PublicKeyToken=null&#39; is not marked as serializable.<br><br>For curiosity, I called&nbsp;__reduce_ex__&nbsp;on&nbsp;a&nbsp;child&nbsp;instance and got&nbsp;the&nbsp;following error:&nbsp;expected Vector2, got Object_1$2<br>
 <br>There are several Microsoft.Xna.Framework.Vector2 members and it looks like they&#39;re being replaced by this&nbsp;Object_1$2 which I assumed at first to be the child class because of its name.  <br>__reduce_ex__ on the parent instances works fine. I&#39;m out of my depth here so I can&#39;t give more meaningful information.<br>
<br><div><span class="gmail_quote">On 10/7/08, <b class="gmail_sendername">Dino Viehland</b> &lt;<a href="mailto:dinov@microsoft.com">dinov@microsoft.com</a>&gt; wrote:</span><blockquote class="gmail_quote" style="margin-top: 0; margin-right: 0; margin-bottom: 0; margin-left: 0; margin-left: 0.80ex; border-left-color: #cccccc; border-left-width: 1px; border-left-style: solid; padding-left: 1ex">
<div lang="EN-US" link="#0000ff" vlink="#800080"><div><p><span style="font-size: 11pt; color: #1f497d">Ahh, that sounds like a bad bug, but I think I know what's causing it – we're hitting the new.NET serialization support because __reduce_ex__ is now defined for you </span><span style="font-size: 11pt; font-family: Wingdings; color: #1f497d">J</span><span style="font-size: 11pt; color: #1f497d">&nbsp; Can you add an override that dispatches __reduce_ex__ to the object version, eg:</span></p>
<p><span style="font-size: 11pt; color: #1f497d">&nbsp;</span></p><p><span style="font-size: 11pt; color: #1f497d">def __reduce_ex__(self, *args): </span></p><p><span style="font-size: 11pt; color: #1f497d">&nbsp;&nbsp;&nbsp; return object.__reduce_ex__(self, *args)</span></p>
<p><span style="font-size: 11pt; color: #1f497d">&nbsp;</span></p><p><span style="font-size: 11pt; color: #1f497d">We should probably do that automatically for user-defined instances which should be easy to do if this works for you.</span></p>
<p><span style="font-size: 11pt; color: #1f497d">&nbsp;</span></p><div style="border-top-color: #000000; border-left-color: #000000; border-right-color: #000000; border-bottom-color: #000000; border-top-width: medium; border-left-width: medium; border-right-width: medium; border-bottom-width: medium; border-top-style: none; border-left-style: none; border-right-style: none; border-bottom-style: none; border-top-color: #b5c4df; border-top-width: 1pt; border-top-style: solid; padding-top: 3pt; padding-right: 0in; padding-bottom: 0in; padding-left: 0in">
<p><b><span style="font-size: 10pt">From:</span></b><span style="font-size: 10pt"> <a href="mailto:users-bounces@lists.ironpython.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">users-bounces@lists.ironpython.com</a> [mailto:<a href="mailto:users-bounces@lists.ironpython.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">users-bounces@lists.ironpython.com</a>] <b>On Behalf Of </b>Serge<br>
<b>Sent:</b> Monday, October 06, 2008 7:36 PM<br><b>To:</b> Discussion of IronPython<br><b>Subject:</b> Re: [IronPython] Serializing IronPython classes</span></p></div><div><span class="e" id="q_11cd53690e8f6994_1"><p>&nbsp;</p>
<p style="margin-bottom: 12pt">Thanks for the heads up, however trying to use cPickle, I still get the error saying that the child class is not marked as serializable..? </p><div><p><span>On 10/7/08, <b>Dino Viehland</b> &lt;<a href="mailto:dinov@microsoft.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">dinov@microsoft.com</a>&gt; wrote:</span></p>
<div><div><p><span style="font-size: 11pt; color: #1f497d">I would strongly encourage you to use cPickle or pickle instead of .NET serialization.&nbsp; In 2.0 all .NET serializable types can also be pickled – they define __reduce_ex__ which handles this.&nbsp; </span></p>
<p><span style="font-size: 11pt; color: #1f497d">&nbsp;</span></p><p><span style="font-size: 11pt; color: #1f497d">First off we should be setting the serializable bit on subclasses that are serializable – that&#39;s just a bug that we&#39;re not doing that.&nbsp; But once we&#39;ve done that the problem w/ .NET serialization is that ultimately we need a static method or type that we can point at that does the deserialization.&nbsp; For a user defined type in Python we will need to be able to deserialize the type, the module the type lives in, and presumably even the ScriptRuntime which holds the module.&nbsp; Pickle handles this by serializing the module &amp; type name but w/o a ScriptRuntime we couldn&#39;t even get at that.&nbsp; We might have been able to require a ScriptRuntime to be smuggled in the StreamingContext but it&#39;s not clear that it would work well.</span></p>
<p><span style="font-size: 11pt; color: #1f497d">&nbsp;</span></p><p><span style="font-size: 11pt; color: #1f497d">So if you really want .NET serialization we can fix the bug – but you&#39;ll need to implement ISerializable and figure out some way to deal getting the class, module, and runtime information saved/restored yourself.</span></p>
<p><span style="font-size: 11pt; color: #1f497d">&nbsp;</span></p><div style="border-top-color: #000000; border-left-color: #000000; border-right-color: #000000; border-bottom-color: #000000; border-top-width: medium; border-left-width: medium; border-right-width: medium; border-bottom-width: medium; border-top-style: none; border-left-style: none; border-right-style: none; border-bottom-style: none; border-top-color: #b5c4df; border-top-width: 1pt; border-top-style: solid; padding-top: 3pt; padding-right: 0in; padding-bottom: 0in; padding-left: 0in">
<p><b><span style="font-size: 10pt">From:</span></b><span style="font-size: 10pt"> <a href="mailto:users-bounces@lists.ironpython.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">users-bounces@lists.ironpython.com</a> [mailto:<a href="mailto:users-bounces@lists.ironpython.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">users-bounces@lists.ironpython.com</a>] <b>On Behalf Of </b>Serge<br>
<b>Sent:</b> Sunday, October 05, 2008 9:24 PM<br><b>To:</b> <a href="mailto:users@lists.ironpython.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">users@lists.ironpython.com</a><br><b>Subject:</b> [IronPython] Serializing IronPython classes</span></p>
</div><p>&nbsp;</p><p>I&#39;ve run into problems with serialization. I have a serializable class defined in C# which gets extended from IP, however when I try to serialize a collection of both parent and child instances, I get an exception saying that the IP generated class is not marked as serializable.<br>
<br> With the lack of attributes, I am guessing I must do something else to enable serialization?<br><br> Regards, Serge.</p></div></div><p style="margin-bottom: 12pt"><br> _______________________________________________<br>
 Users mailing list<br><a href="mailto:Users@lists.ironpython.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">Users@lists.ironpython.com</a><br><a href="http://lists.ironpython.com/listinfo.cgi/users-ironpython.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://lists.ironpython.com/listinfo.cgi/users-ironpython.com</a></p>
</div><p>&nbsp;</p></span></div></div></div><br>_______________________________________________<br> Users mailing list<br><a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:Users@lists.ironpython.com">Users@lists.ironpython.com</a><br>
<a onclick="return top.js.OpenExtLink(window,event,this)" href="http://lists.ironpython.com/listinfo.cgi/users-ironpython.com" target="_blank">http://lists.ironpython.com/listinfo.cgi/users-ironpython.com</a><br><br></blockquote>
</div><br>