[IronPython] strange runtime error hosting Iron Python in C# app

Dino Viehland dinov at exchange.microsoft.com
Tue Apr 3 00:37:23 CEST 2007

How exactly are you doing this?  If I take the code you've provided and put it into a .cs file, compile it to a DLL, and import it I get:

IronPython 1.1b1 (1.1) on .NET 2.0.50727.312
Copyright (c) Microsoft Corporation. All rights reserved.
>>> import clr
>>> clr.AddReference('test')
>>> import FooUser, FooConcrete1
>>> FooUser.FooInt(FooConcrete1())
>>> ^Z

Are you doing something different?

From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Matthew Swank
Sent: Monday, April 02, 2007 3:03 PM
To: users at lists.ironpython.com
Subject: [IronPython] strange runtime error hosting Iron Python in C# app

Given a set of classes in a c# Library like the following:

    public interface IFoo
        int Bar { get;}

    public abstract class FooBase : IFoo
        public abstract int Bar { get;}

    public class FooConcrete1 : FooBase
        public override int Bar { get { return 1; } }

and a C# consumer:
       public class FooUser
        public static int FooInt(IFoo a)
            return a.Bar;

if I call FooInt from Python I'll get: "We Encountered an error: expected IFoo, got FooConcrete1".

I suspect the error stems from adding an assembly as a reference inside the python code in addition to referencing it in the C# project.  If this is the case, how do I make referenced assemblies visible to the hosted python module w/o using AddReference...?


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20070402/b316807d/attachment.html>

More information about the Ironpython-users mailing list