<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://forums.asp.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>IronPython for ASP.NET</title><link>http://forums.asp.net/1098.aspx</link><description>Discussions/Questions about IronPython for ASP.NET</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>Re: Serialize complex objects in IronPython for ASP.NET?</title><link>http://forums.asp.net/thread/3025005.aspx</link><pubDate>Fri, 20 Mar 2009 19:34:32 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3025005</guid><dc:creator>JoshuaP_Ohio</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3025005.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1098&amp;PostID=3025005</wfw:commentRss><description>&lt;p&gt;Hello Johan,&lt;/p&gt;
&lt;p&gt;What is the target of your serialized object?&amp;nbsp; Depending on the intended usage, there are other serialization types available:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;div&gt;Simple XML generator on my blog here: &lt;a href="http://www.globalherald.net/jb01/weblog/20.html"&gt;http://www.globalherald.net/jb01/weblog/20.html&lt;/a&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;Python Pickles might work, if your target is also Python: &lt;a class="" href="http://docs.python.org/library/pickle.html" target="_blank"&gt;http://docs.python.org/library/pickle.html&lt;/a&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;Google Protocol Buffers offer an extremely fast and compact format for objects being serialized between Python, Java, C++, and .NET languages: a) &lt;a class="" href="http://code.google.com/apis/protocolbuffers/" target="_blank"&gt;http://code.google.com/apis/protocolbuffers/&lt;/a&gt;&amp;nbsp;and b) &lt;a class="" href="http://code.google.com/p/protobuf-net/" target="_blank"&gt;http://code.google.com/p/protobuf-net/&lt;/a&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;Does this help?&lt;/p&gt;
&lt;p&gt;Cheers,&lt;/p&gt;
&lt;p&gt;-JK&lt;/p&gt;</description></item><item><title>Re: Serialize complex objects in IronPython for ASP.NET?</title><link>http://forums.asp.net/thread/1799930.aspx</link><pubDate>Thu, 12 Jul 2007 09:35:17 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1799930</guid><dc:creator>jdanforth</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1799930.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1098&amp;PostID=1799930</wfw:commentRss><description>&lt;p&gt;Hi, back again... I&amp;#39;ve installed IronPython 2.0A1 which I believe is based on the Silverlight DLR stuff and done some more testing. Here&amp;#39;s the code I&amp;#39;m runnig from the ipy.exe console:&lt;/p&gt;&lt;span style="FONT-SIZE:10pt;COLOR:blue;FONT-FAMILY:&amp;#39;Courier New&amp;#39;;mso-ansi-language:EN-GB;mso-no-proof:yes;"&gt;&lt;font color="#0000ff" size="2"&gt;
&lt;p&gt;import&lt;/font&gt;&lt;font size="2"&gt;&lt;font color="#000000"&gt; clr&lt;/font&gt;&lt;/p&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;import&lt;/font&gt;&lt;font size="2"&gt;&lt;font color="#000000"&gt; System&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; 
&lt;p&gt;clr.AddReference(&lt;/font&gt;&lt;font color="#800000" size="2"&gt;&amp;quot;System.Xml&amp;quot;&lt;/font&gt;&lt;font size="2"&gt;)&lt;/p&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;
&lt;p&gt;from&lt;/font&gt;&lt;font color="#000000" size="2"&gt; System &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;import&lt;/font&gt;&lt;font size="2"&gt;&lt;font color="#000000"&gt; *&lt;/font&gt;&lt;/p&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;
&lt;p&gt;from&lt;/font&gt;&lt;font color="#000000" size="2"&gt; System.IO &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;import&lt;/font&gt;&lt;font size="2"&gt;&lt;font color="#000000"&gt; *&lt;/font&gt;&lt;/p&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;
&lt;p&gt;from&lt;/font&gt;&lt;font color="#000000" size="2"&gt; System.Xml.Serialization &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;import&lt;/font&gt;&lt;font size="2"&gt;&lt;font color="#000000"&gt; *&lt;/font&gt;&lt;/p&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;class&lt;/font&gt;&lt;font size="2"&gt;&lt;font color="#000000"&gt; Myclass(System.Object):&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; 
&lt;blockquote&gt;
&lt;p&gt;name = None&lt;/p&gt;
&lt;p&gt;age = 0&lt;/p&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;def&lt;/font&gt;&lt;font size="2"&gt; __init__(self):&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; 
&lt;blockquote&gt;
&lt;p&gt;self.name = &lt;/font&gt;&lt;font color="#800000" size="2"&gt;&amp;quot;&amp;quot;&lt;/p&gt;&lt;/font&gt;&lt;font size="2"&gt;
&lt;p&gt;self.age = 0&lt;/p&gt;&lt;/blockquote&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;def&lt;/font&gt;&lt;font size="2"&gt; __init__(self, n, a):&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; 
&lt;blockquote&gt;
&lt;p&gt;self.name = n&lt;/p&gt;
&lt;p&gt;self.age = a&lt;/p&gt;&lt;/blockquote&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;def&lt;/font&gt;&lt;font size="2"&gt; __str__(self):&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; 
&lt;blockquote&gt;
&lt;p&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;return&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font color="#800000" size="2"&gt;&amp;quot;%s, %s years old&amp;quot;&lt;/font&gt;&lt;font size="2"&gt;%(self.name,self.age)&lt;/p&gt;&lt;/blockquote&gt;&lt;/blockquote&gt;
&lt;p&gt;a = Myclass(&lt;/font&gt;&lt;font color="#800000" size="2"&gt;&amp;quot;Angie&amp;quot;&lt;/font&gt;&lt;font size="2"&gt;,66)&lt;/p&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;print&lt;/font&gt;&lt;font size="2"&gt;&lt;font color="#000000"&gt;(a)&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; 
&lt;p&gt;ser = XmlSerializer(a.GetType())&lt;/p&gt;writer = StreamWriter(&lt;/font&gt;&lt;font color="#800000" size="2"&gt;&amp;quot;C:/dump.xml&amp;quot;&lt;/font&gt;&lt;font size="2"&gt;)&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; 
&lt;p&gt;ser.Serialize(writer, a)&lt;/p&gt;
&lt;p&gt;writer.Close()&lt;/p&gt;
&lt;p&gt;&lt;/font&gt;&lt;/span&gt;And here&amp;#39;s the output from running that piece:&amp;nbsp;&lt;/p&gt;
&lt;p&gt;C:\IronPython-2.0A1\IronPython-2.0A1&amp;gt;ipy Program.py&lt;br /&gt;Angie, 66 years old&lt;br /&gt;Traceback (most recent call last):&lt;br /&gt;&amp;nbsp; File Program.py, line 26, in Initialize&lt;br /&gt;&amp;nbsp; File , line 0, in _stub_##31&lt;br /&gt;&amp;nbsp; File , line 0, in NonDefaultNew##36&lt;br /&gt;&amp;nbsp; File , line 0, in .ctor##38&lt;br /&gt;&amp;nbsp; File System.Xml, line unknown, in .ctor&lt;br /&gt;&amp;nbsp; File System.Xml, line unknown, in .ctor&lt;br /&gt;&amp;nbsp; File System.Xml, line unknown, in ImportTypeMapping&lt;br /&gt;&amp;nbsp; File System.Xml, line unknown, in GetTypeModel&lt;br /&gt;&amp;nbsp; File System.Xml, line unknown, in GetTypeDesc&lt;br /&gt;&amp;nbsp; File System.Xml, line unknown, in CheckSupported&lt;br /&gt;SystemError: IronPython.NewTypes.System.Object_1 cannot be serialized because it does not have a parameterless constructor.&lt;/p&gt;
&lt;p&gt;Hope this helps. Again, I&amp;#39;m new dynamic languages and not sure how well serialization is supposed to work here. I&amp;#39;m also unfamilar to how constructor overloading works in python I&amp;#39;m afraid, as it might have something to do with the error in this case.&lt;/p&gt;
&lt;p&gt;Thanks, &lt;br /&gt;Johan&lt;/p&gt;</description></item><item><title>Re: Serialize complex objects in IronPython for ASP.NET?</title><link>http://forums.asp.net/thread/1615661.aspx</link><pubDate>Mon, 12 Mar 2007 01:57:15 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1615661</guid><dc:creator>davidebb</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1615661.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1098&amp;PostID=1615661</wfw:commentRss><description>&lt;p&gt;Hi Johan,&lt;/p&gt;
&lt;p&gt;To isolate a bit, can you try running the same logic directly from ipy.exe instead of through ASP.NET?&amp;nbsp; If it happens there as well, then at least we know ASP.NET is not in the picture.&lt;/p&gt;
&lt;p&gt;thanks,&lt;br /&gt;David&lt;/p&gt;</description></item><item><title>Serialize complex objects in IronPython for ASP.NET?</title><link>http://forums.asp.net/thread/1614744.aspx</link><pubDate>Sat, 10 Mar 2007 19:00:58 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1614744</guid><dc:creator>jdanforth</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1614744.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1098&amp;PostID=1614744</wfw:commentRss><description>&lt;p&gt;I'm trying to create an XmlSerializer in an IronPython ASP.NET page to serialize an object with a few properties, but I get this error from the compiler:&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;strong&gt;Parser Error Message: &lt;/strong&gt;Unable to generate a temporary class (result=1).&lt;br /&gt;error CS0012: The type 'IronMath.ISlice' is defined in an assembly that is not referenced. You must add a reference to assembly 'IronMath, Version=1.0.60816.1877, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.&lt;/p&gt;
&lt;p&gt;I've tried a number of things to get this to work. Added this in my web.config:&lt;/p&gt;&lt;font color=#0000ff size=2&gt;
&lt;p&gt;&amp;lt;&lt;/p&gt;&lt;/font&gt;&lt;font color=#800000 size=2&gt;add&lt;/font&gt;&lt;font color=#0000ff size=2&gt; &lt;/font&gt;&lt;font color=#ff0000 size=2&gt;assembly&lt;/font&gt;&lt;font color=#0000ff size=2&gt;=&lt;/font&gt;&lt;font size=2&gt;"&lt;/font&gt;&lt;font color=#0000ff size=2&gt;IronMath, Version=1.0.60816.1877, Culture=neutral, PublicKeyToken=31bf3856ad364e35&lt;/font&gt;&lt;font size=2&gt;"&lt;/font&gt;&lt;font color=#0000ff size=2&gt;/&amp;gt;
&lt;p&gt;&lt;/p&gt;&lt;/font&gt;But to no change. IronMath&amp;nbsp;is in my bin directory. I've also tried to add reference to IronMath in code, but nothing works.&amp;nbsp;This is my code:&lt;font size=2&gt;
&lt;p&gt;a = MyClass(&lt;/p&gt;&lt;/font&gt;&lt;font color=#800000 size=2&gt;"Johan"&lt;/font&gt;&lt;font size=2&gt;,40)&lt;/font&gt;&lt;font size=2&gt;
&lt;p&gt;ser = XmlSerializer(a.GetType())&lt;/p&gt;
&lt;p&gt;writer = StreamWriter(&lt;/p&gt;&lt;/font&gt;&lt;font color=#800000 size=2&gt;"c:/dump.xml"&lt;/font&gt;&lt;font size=2&gt;)
&lt;p&gt;ser.Serialize(writer,a)&lt;/p&gt;
&lt;p&gt;writer.Close()&lt;/p&gt;
&lt;p&gt;MyClass looks like this:&lt;/p&gt;&lt;font color=#0000ff size=2&gt;
&lt;p&gt;class&lt;/p&gt;&lt;/font&gt;&lt;font size=2&gt; MyClass:
&lt;p&gt;&lt;/p&gt;&lt;/font&gt;&lt;font color=#0000ff size=2&gt;&amp;nbsp; def&lt;/font&gt;&lt;font size=2&gt; __init__(self, name, height):
&lt;p&gt;&amp;nbsp; self.name = name&lt;/p&gt;
&lt;p&gt;&amp;nbsp; self.height = height&lt;/p&gt;&lt;/font&gt;
&lt;p&gt;&lt;/p&gt;&lt;/font&gt;I guess it's a general problem&amp;nbsp;to serialize&amp;nbsp;objects in&amp;nbsp;Python... Or is there a trick?&amp;nbsp;I could define MyClass and code to serialize in a c# assembly, but I would like to do it in Python only.
&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description></item></channel></rss>