title: IronPython - "AttributeError: object has no attribute" with custom classes
body: <p>This seems like there is just a simple error that I cannot figure out. I am using IronPython in a C# WPF application and am getting the following error when trying to run a function from a custom C# class:<code>AttributeError: 'MyScriptingFunctions' object has no attribute 'Procedure'</code>. </p>
  
  <p>The python script I'm running is very simple and has two lines. Line 1 executes fine, the error occurs on line 2.</p>
  
  <pre><code>    txt.Text = "some text"
      MyFunc.Procedure(5)
  </code></pre>
  
  <p>MyScriptingFunctions.cs:</p>
  
  <pre><code>class MyScriptingFunctions
  {
      public MyScriptingFunctions() {}
  
      public void Procedure(int num)
      {
          Console.WriteLine("Executing procedure " + num); 
      }
  }
  </code></pre>
  
  <p>Here is how I setup the IronPython engine:</p>
  
  <pre><code>     private void btnRunScript_Click(object sender, RoutedEventArgs e)
       {
          MyScriptingFunctions scriptFuncs = new MyScriptingFunctions();
          ScriptEngine engine = Python.CreateEngine();
          ScriptScope scope = engine.CreateScope();
  
          ScriptRuntime runtime = engine.Runtime;
          runtime.LoadAssembly(typeof(String).Assembly);
          runtime.LoadAssembly(typeof(Uri).Assembly);
  
          //Set Variable for the python script to use
          scope.SetVariable("txt", fullReadResultsTextBox);
          scope.SetVariable("MyFunc", scriptFuncs);
          string code = this.scriptTextBox.Text;
          try
          {
              ScriptSource source = engine.CreateScriptSourceFromString(code, SourceCodeKind.Statements);
              source.Execute(scope);
          }
          catch (Exception ex)
          {
              ExceptionOperations eo;
              eo = engine.GetService&lt;ExceptionOperations&gt;();
              string error = eo.FormatException(ex);
  
              MessageBox.Show(error, "There was an Error");
              return;
          }
  
      }
  </code></pre>
  
  <p>I am simply setting two variables:<code>txt</code> which is of type <code>System.Windows.Controls.TextBox</code>, and <code>MyFunc</code> which is an object of my custom class <code>MyScriptingFunctions</code>. </p>
  
  <p>What am I doing wrong and why does the python script execute the TextBox methods correctly and not my custom class's methods?</p>