<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">

<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 12 (filtered medium)">
<style>
<!--
 /* Font Definitions */
 @font-face
        {font-family:Wingdings;
        panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p
        {mso-style-priority:99;
        mso-margin-top-alt:auto;
        margin-right:0in;
        mso-margin-bottom-alt:auto;
        margin-left:0in;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
span.gmailquote
        {mso-style-name:gmail_quote;}
span.e
        {mso-style-name:e;}
span.EmailStyle20
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page Section1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.Section1
        {page:Section1;}
-->
</style>
<!--[if gte mso 9]><xml>
 <o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
 <o:shapelayout v:ext="edit">
  <o:idmap v:ext="edit" data="1" />
 </o:shapelayout></xml><![endif]-->
</head>

<body lang=EN-US link=blue vlink=purple>

<div class=Section1>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>Ok, upon looking into this some more, I&#8217;m sad to say it looks
like this won&#8217;t work right now </span><span style='font-size:11.0pt;font-family:
Wingdings;color:#1F497D'>L</span><span style='font-size:11.0pt;font-family:
"Calibri","sans-serif";color:#1F497D'>.&nbsp; We need to figure out a way to run the
serialization for just the base class and how to do that isn&#8217;t entirely obvious
&#8211; so it probably won&#8217;t make 2.0.&nbsp; I&#8217;ve opened a bug to track the issue though: <a
href="http://www.codeplex.com/IronPython/WorkItem/View.aspx?WorkItemId=18823">http://www.codeplex.com/IronPython/WorkItem/View.aspx?WorkItemId=18823</a>&nbsp;
Feel free to vote on it so we&#8217;ll fix it sooner.<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p>&nbsp;</o:p></span></p>

<div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in'>

<p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span
style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>
users-bounces@lists.ironpython.com [mailto:users-bounces@lists.ironpython.com] <b>On
Behalf Of </b>Serge<br>
<b>Sent:</b> Monday, October 06, 2008 9:15 PM<br>
<b>To:</b> Discussion of IronPython<br>
<b>Subject:</b> Re: [IronPython] Serializing IronPython classes<o:p></o:p></span></p>

</div>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal style='margin-bottom:12.0pt'>Okay now this is getting
interesting. I assumed that the warning was about the child class, but I'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 'IronPython.NewTypes.Engine.Object_1$2' in Assembly 'Snippets.scripting,
Version=<a href="http://0.0.0.0">0.0.0.0</a>, Culture=neutral,
PublicKeyToken=null' 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'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'm out of my depth here so I
can't give more meaningful information.<o:p></o:p></p>

<div>

<p class=MsoNormal><span class=gmailquote>On 10/7/08, <b>Dino Viehland</b> &lt;<a
href="mailto:dinov@microsoft.com">dinov@microsoft.com</a>&gt; wrote:</span><o:p></o:p></p>

<div>

<div>

<p><span style='font-size:11.0pt;color:#1F497D'>Ahh, that sounds like a bad
bug, but I think I know what's causing it &#8211; we're hitting the new.NET
serialization support because __reduce_ex__ is now defined for you </span><span
style='font-size:11.0pt;font-family:Wingdings;color:#1F497D'>J</span><span
style='font-size:11.0pt;color:#1F497D'>&nbsp; Can you add an override that
dispatches __reduce_ex__ to the object version, eg:</span><o:p></o:p></p>

<p><span style='font-size:11.0pt;color:#1F497D'>&nbsp;</span><o:p></o:p></p>

<p><span style='font-size:11.0pt;color:#1F497D'>def __reduce_ex__(self, *args):
</span><o:p></o:p></p>

<p><span style='font-size:11.0pt;color:#1F497D'>&nbsp;&nbsp;&nbsp; return
object.__reduce_ex__(self, *args)</span><o:p></o:p></p>

<p><span style='font-size:11.0pt;color:#1F497D'>&nbsp;</span><o:p></o:p></p>

<p><span style='font-size:11.0pt;color:#1F497D'>We should probably do that
automatically for user-defined instances which should be easy to do if this
works for you.</span><o:p></o:p></p>

<p><span style='font-size:11.0pt;color:#1F497D'>&nbsp;</span><o:p></o:p></p>

<div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in'>

<p><b><span style='font-size:10.0pt'>From:</span></b><span style='font-size:
10.0pt'> <a href="mailto:users-bounces@lists.ironpython.com" target="_blank">users-bounces@lists.ironpython.com</a>
[mailto:<a href="mailto:users-bounces@lists.ironpython.com" target="_blank">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><o:p></o:p></p>

</div>

<div>

<p>&nbsp;<o:p></o:p></p>

<p style='margin-bottom:12.0pt'>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..? <o:p></o:p></p>

<div>

<p>On 10/7/08, <b>Dino Viehland</b> &lt;<a href="mailto:dinov@microsoft.com"
target="_blank">dinov@microsoft.com</a>&gt; wrote:<o:p></o:p></p>

<div>

<div>

<p><span style='font-size:11.0pt;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 &#8211; they define __reduce_ex__ which
handles this.&nbsp; </span><o:p></o:p></p>

<p><span style='font-size:11.0pt;color:#1F497D'>&nbsp;</span><o:p></o:p></p>

<p><span style='font-size:11.0pt;color:#1F497D'>First off we should be setting
the serializable bit on subclasses that are serializable &#8211; that's just a bug
that we're not doing that.&nbsp; But once we'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't even get at that.&nbsp; We might have been able to require a
ScriptRuntime to be smuggled in the StreamingContext but it's not clear that it
would work well.</span><o:p></o:p></p>

<p><span style='font-size:11.0pt;color:#1F497D'>&nbsp;</span><o:p></o:p></p>

<p><span style='font-size:11.0pt;color:#1F497D'>So if you really want .NET
serialization we can fix the bug &#8211; but you'll need to implement ISerializable
and figure out some way to deal getting the class, module, and runtime
information saved/restored yourself.</span><o:p></o:p></p>

<p><span style='font-size:11.0pt;color:#1F497D'>&nbsp;</span><o:p></o:p></p>

<div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in'>

<p><b><span style='font-size:10.0pt'>From:</span></b><span style='font-size:
10.0pt'> <a href="mailto:users-bounces@lists.ironpython.com" target="_blank">users-bounces@lists.ironpython.com</a>
[mailto:<a href="mailto:users-bounces@lists.ironpython.com" target="_blank">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">users@lists.ironpython.com</a><br>
<b>Subject:</b> [IronPython] Serializing IronPython classes</span><o:p></o:p></p>

</div>

<p>&nbsp;<o:p></o:p></p>

<p>I'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.<o:p></o:p></p>

</div>

</div>

<p style='margin-bottom:12.0pt'><br>
_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@lists.ironpython.com" target="_blank">Users@lists.ironpython.com</a><br>
<a href="http://lists.ironpython.com/listinfo.cgi/users-ironpython.com"
target="_blank">http://lists.ironpython.com/listinfo.cgi/users-ironpython.com</a><o:p></o:p></p>

</div>

<p>&nbsp;<o:p></o:p></p>

</div>

</div>

</div>

<p class=MsoNormal style='margin-bottom:12.0pt'><br>
_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@lists.ironpython.com">Users@lists.ironpython.com</a><br>
<a href="http://lists.ironpython.com/listinfo.cgi/users-ironpython.com"
target="_blank">http://lists.ironpython.com/listinfo.cgi/users-ironpython.com</a><o:p></o:p></p>

</div>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

</div>

</body>

</html>