[IronPython] Bug in engine.LoadAssembly(...) -> PythonImportError

Martin Maly Martin.Maly at microsoft.com
Sat Feb 11 19:58:08 CET 2006


Your TestOther class is not public so IronPython can't access it, hence the exception.

Martin

-----Original Message-----
From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Stanislas Pinte
Sent: Friday, February 10, 2006 4:10 AM
To: users at lists.ironpython.com
Subject: [IronPython] Bug in engine.LoadAssembly(...) -> PythonImportError

Hello,

I have troubles importing classes defined in my own assembly:

[Release]> ./TestImport.exe

Unhandled Exception: IronPython.Runtime.PythonImportError: No module named Other

   at IronPython.Runtime.ReflectedMethodBase.Invoke(MethodBinding binding)
..
   at TestAccessOtherNamespace.Initialize() in c:TempTestImportTestImportbin
ReleaseTestAccessOtherNamespace.py:line 1

I am actually trying to give access to all the namespaces defined in the main assembly, like that:


class Program
  {
    static void Main(string[] args)
    {
      PythonEngine engine = new PythonEngine();
      //allow python scrupts to import all classes of my assembly
      engine.LoadAssembly(Assembly.GetAssembly(typeof(Program)));
      engine.AddToPath(@".");
      engine.Import("TestAccessOtherNamespace"); 
    }
  }

Am I missing anything? 

See attached full source code (c# program, and python script).

Thanks a lot,

Stan.







More information about the Ironpython-users mailing list