title: Calling IronPython object from C# with mono
body: <p>I have the following IronPython code.</p>
  
  <pre><code>class Hello:
      def __init__(self):
          pass
      def add(self, x, y):
          return (x+y)
  </code></pre>
  
  <p>I need to call this from C#, and I came up with the following code.</p>
  
  <pre><code>using System;
  using IronPython.Hosting;
  using IronPython.Runtime;
  using IronPython;
  using Microsoft.Scripting.Hosting;
  using Microsoft.Scripting;
  
  class Hello {
      public static void Main()
      {
          ScriptEngine engine = Python.CreateEngine();
          ScriptSource script = engine.CreateScriptFromSourceFile("myPythonScript.py");
          ScriptScope scope = engine.CreateScope();
  
          script.Execute(scope);
      }
  }
  </code></pre>
  
  <p>After copying IronPython.dll, I run the following command. (I tried to run gacutil, but I got some <a href="https://stackoverflow.com/questions/3902032/gac-gacutil-not-working-with-ironpython-dll-on-mono">errors</a>.</p>
  
  <pre>
   dmcs /r:IronPython.dll callipy.cs
  </pre>
  
  <p>But I got some error messages as follows.</p>
  
  <pre>
  Could not load file or assembly 'Microsoft.Scripting.ExtensionAttribute, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies.
  Missing method .ctor in assembly /Users/smcho/Desktop/cs/namespace/IronPython.dll, type System.Runtime.CompilerServices.ExtensionAttribute
  Can't find custom attr constructor image: /Users/smcho/Desktop/cs/namespace/IronPython.dll mtoken: 0x0a000080
  Could not load file or assembly 'Microsoft.Scripting.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies.
  Could not load file or assembly 'Microsoft.Scripting.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies.
  Could not load file or assembly 'Microsoft.Scripting.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies.
  ...
  </pre>
  
  <p>It seems like that IronPython needs Microsoft.Scipting.Core, but with mono I don't know what to do?</p>
  
  <ul>
  <li>Can C# run IronPython object on Mono? If so, how to do that?</li>
  </ul>