Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I create a .NET assembly in IronPython and call it from C#?
    text
    copied!<p>I want to create an assembly using IronPython can call it from C#. Here are two things I am <em>not</em> asking.</p> <ol> <li><p>I'm not asking how to call C# from IronPython. The easiest documentation to find describes how to call C# from inside IronPython. (For example, the tutorial that ships with IronPython.) I want to do the opposite, call IronPython from C#. </p></li> <li><p>I'm not asking how to embed the IronPython interpreter. I've found several useful references (e.g. <a href="http://blogs.microsoft.co.il/blogs/berniea/archive/2008/12/04/extending-your-c-application-with-ironpython.aspx" rel="noreferrer">here</a> and <a href="http://lists.ironpython.com/pipermail/users-ironpython.com/2005-July/000855.html" rel="noreferrer">here</a>) on how to call the IronPython interpreter from C#. That's helpful, but I'm more interested in creating a compiled assembly from IronPython. That is, I'd like to make method calls into the IronPython assembly rather than passing source code strings to the interpreter.</p></li> </ol> <p>Once I've created the assembly, what are some tips on calling into it? One <a href="http://www.sogeti-phoenix.com/Blogs/post/2008/03/Creating-and-Consuming-IronPython-Assemblies.aspx" rel="noreferrer">blog post</a> I found said:</p> <blockquote> <p>... calling a Python assembly from C# is non-trivial. That python assembly contains dynamic types, which are not easily reflected into useful C# objects.</p> </blockquote> <p>Do you know any sort of cheat sheet for passing basic data types between IronPython and C#?</p> <p><strong>Update</strong>: The scenario I am most interested in for now is passing two or three <code>double</code> values into Python and getting one or two <code>double</code> values back. If I could pass in a string and get a string back that would be terrific, but my first priority is just passing numbers back and forth.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload