[IronPython] IronPython interop problem
dinov at exchange.microsoft.com
Fri Aug 25 21:46:30 CEST 2006
The problem you're running into is that we won't expose the Python type by the names you compile it as - this is the weirdness you're seeing versus a C# compiled assembly.
There's a couple of ways to deal with this. One is to host IronPython and use the PythonEngine interfaces to expose objects, create instances, etc... This is the preferred mechanism - for your scenario you may need to make a small shim in C# that enables access to the IronPython engine because we don't mark the type as being ComVisible (and we explicitly turn off COM visibility for all types in the assembly unless they opt-in). I'm actually not certain if our types that get created on the fly are COM visible, but even if they are IDispatch currently won't know about the way we plug-in here.
We also have a HIGHLY EXPERIMENTAL static type compiler - unfortunately there is plenty of valid Python code that can't be compiled by it yet so I'd suggest you go with the 1st route.
This is a very interesting scenario though and we'll probably want to look at what we can do in the future to make this better. If you want to let us know more about what you're trying to accomplish in the end it might help us ensure this meets your needs in the future.
From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Marc-André Belzile
Sent: Friday, August 25, 2006 11:11 AM
To: users at lists.ironpython.com
Subject: [IronPython] IronPython interop problem
I'm hosting the CLR (.NET 2.0) in an unmanaged C++ app in order to access objects from .NET assemblies with IDispatch. This is working fine for C# assemblies but failed for IP assemblies.
The call to _AppDomain.CreateInstance below returns this error: 80131522, which I couldn't find in the doc.
My unmanaged code:
HRESULT hr = pDomain->QueryInterface( &spAppDomain.p );
assert( !hr );
hr = spAppDomain->CreateInstance( assyname,classname,&spHandle );
My test class in
I compiled the PI assbly with VS2005 using the IDE prototype. The IL code looks rather odd though compared to a C# assbly.
| M A N I F E S T
| | .class public auto ansi
| | extends [IronPython]IronPython.Runtime.CustomDict
| |___[STF] ExtraKeysCache : public static string
| |___[STF] MyClass : public static object
| |___[STF] __doc__ : public static object
| |___[STF] __name__ : public static object
| |___[STF] myModule__py : public static class [IronPython]IronPython.Runtime.PythonModule
| |___[STM] .cctor : void()
| |___[MET] .ctor : void()
| |___[STM] Foo$f4 : object(class [IronPython]IronPython.Runtime.FunctionEnvironment4)
| |___[MET] GetExtraKeys : object()
| |___[MET] Initialize : void()
| |___[STM] Main : int32()
| | MyClass$maker4 : class [mscorlib]System.Collections.Generic.IDictionary`2<object,object>(class [IronPython]IronPython.Runtime.FunctionEnvironment,class [IronPython]IronPython.Runtime.ICallerContext)
| |___[MET] TryGetExtraValue : bool(object,object&)
| |___[MET] TrySetExtraValue : bool(object,object)
Is this a known limitation ? Or maybe there is another way of getting at IP classes from unmanaged code ?
thanks for your help!
Marc-André BELZILE - sdk software engineer, softimage|xsi _______________________________________________
users mailing list
users at lists.ironpython.com
More information about the Ironpython-users