[Python.NET] problem with inheritance? ironpython ok, python.net - different
Brian Lloyd
brian.lloyd at revolutionhealth.com
Fri Oct 19 18:54:51 CEST 2007
> I really don't know when I can access a working Windows box with .NET
> and VS 2005. My Windows box has a hardware problem and I don't have time
> and money to fix the box until next month.
>
> Brian seems to be very busy, too. I haven't heard from him for quite a
> while.
...but I'm still alive ;)
On the original question here - David, you've basically run into the edge
of the integration between python and .net here.
The object that gets passed to your event handler by the CLR will always
be the of actual .net class, not the python subclass. This is because
the python subclass is not a real CLR class (it is only visible in Python),
which is not the case in IronPython (python classes are bona fide CLR
classes).
Technically it would be possible to have the integration machinery track
'wrapped' instances so that a transition from Python -> CLR -> Python would
lookup and pass the wrapped instance, but that's not there today (and I'm
not sure what effect that would have on perf and memory usage).
If there's no way around it, you could implement a poor man's version of
this in your app using GCHandle to map back and forth between managed
objects and the wrapped Python instances -- but its usually easier to
find some other way around the problem ;)
hope this helps,
--------------------------
Brian Lloyd
brian.lloyd at revolutionhealth.com
More information about the PythonDotNet
mailing list