[IronPython] Trouble calling a method on a .NET object

Curt Hagenlocher curt at hagenlocher.org
Wed Jun 11 09:35:11 PDT 2008


Your code works as expected if you make the "Concrete" class public instead
of internal. Please file this as an issue on CodePlex at
http://www.codeplex.com/IronPython


On Wed, Jun 11, 2008 at 6:09 AM, Orian, Helmut <helmut.orian at schema.de>
wrote:

> I'm having trouble calling a method on one of my .NET objects.
>
> if you compile the following repro into a "test.dll":
>
>
> namespace Test {
>        public interface ISomeInterface {
>                string Greet();
>        }
>
>        public abstract class Base {}
>
>        public static class SomeFactory {
>                public static object Get() {
>                        return new Concrete();
>                }
>        }
>
>        internal class Concrete : Base, ISomeInterface {
>                public string Greet() {
>                        return "Hello world!";
>                }
>        }
> }
>
>
> and try to use them:
>
> >>> import clr
> >>> clr.AddReference("test")
> >>> from Test import *
> >>> o = SomeFactory.Get()
> >>> print("Greet" in dir(o))
> True
> >>> print(o.Greet())
>
> Traceback (most recent call last):
>  File "<stdin>", line 1, in <module>
> TypeError: expected ISomeInterface, got Base
>
>
> To me it looks like a bug regarding collection of polymorphic
> information on .NET types;
> or am I missing something?
>
>
> Thanks,
> Helmut
>
>
>
> ---------------------------------------------------------------------------
>
>  An- und Abmeldung zur SCHEMA Mailingliste unter http://www.schema.de/mail
>
> ---------------------------------------------------------------------------
>
>
> _______________________________________________
> Users mailing list
> Users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ironpython.com/pipermail/users-ironpython.com/attachments/20080611/2fd7d0f0/attachment-0001.htm>


More information about the Users mailing list