[IronPython] Subclassing then instantiating from C#
Michael Foord
fuzzyman at voidspace.org.uk
Tue Aug 26 20:53:11 CEST 2008
Curt Hagenlocher wrote:
> This isn't really a supported scenario today. There is a CLS type
> emitted for your class but it's emitted at runtime. See also
> http://blogs.msdn.com/shrib/archive/2008/07/24/cls-compilation-of-ironpython.aspx
>
> Before joining the IronPython team, I started a project that
> would allow this operation -- but I haven't been able to put any time
> into it recently.
It's still something I'm interested in (Coils). There is also a non-zero
chance that Resolver Systems will *need* something like this at some
point - if so we will probably push Coils forward.
For the specific use case I would use ObjectOperations to create
instances of the IronPython class at runtime. Until you can get a
reference to the type at compile time the fact that it subclasses a C#
type isn't relevant.
Alternatively you can create a factory function (in Python) to create
instances - and call that from C#, casting the returned object to the
known type.
Michael
>
> On Tue, Aug 26, 2008 at 11:44 AM, hellosticky <hellosticky at gmail.com
> <mailto:hellosticky at gmail.com>> wrote:
>
> Hi, I have a C#.NET DLL that has an abstract class. I subclass
> this class in IronPython, and then build a DLL using pyc.py. Now,
> I'd like to load this IronPython Assembly from another C# project,
> instantiate the class (using something like Assembly.GetType())
> and call the virtual method on it.
>
> The override of the abstract method worked and the DLL got build,
> but when I load it in Reflector, I don't see any classes that
> subclass the original .NET class. Any ideas?
>
> Thanks,
>
> _______________________________________________
> Users mailing list
> Users at lists.ironpython.com <mailto:Users at lists.ironpython.com>
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Users mailing list
> Users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>
--
http://www.ironpythoninaction.com/
http://www.voidspace.org.uk/
http://www.trypython.org/
http://www.ironpython.info/
http://www.theotherdelia.co.uk/
http://www.resolverhacks.net/
More information about the Ironpython-users
mailing list