[Python.NET] Python.NET and COM CoClasses
Brian Lloyd
brian at zope.com
Wed Mar 31 11:11:07 EST 2004
> I tried to use Python.NET with COM objects, and I couldn't
> get it to work. The documentation says it works, so I
> assume either that there is a bug or that I'm doing
> something wrong.
>
> Background: I have a large COM library of vtbl-based
> interfaces, not accessible through Win32all. They can be
> accessed through ctypes but it's slow and there are a many
> cases where the autogenerated wrappers are wrong. This
> library ships with .NET assemblies which properly deal with
> those special cases, so that's why I'm interested in
> Python.NET.
>
> What happens is I can import the interfaces, and I can
> import the CoClasses, but Python.NET seems to think the
> CoClasses are interfaces too. So when I try to instantiate
> an object, it fails with a message "interface constructor
> requires a single argument" or something like that.
>
> Any ideas?
Hi Bruce - unfortunately I'm not much of an expert on this ;(
I've mostly tested things like MSAgent that exposed automation
objects.
That said, unless I've really messed up somewhere, any class that
you can instantiate from C# should be able to be instantiated
from Python. Have you tried using those CoClasses from a test
C# program?
One thing that threw me off when I first tested MSAgent was the
fact that there were really 2 dlls (AgentObjects.dll, AxAgentObjects.dll),
one of which had only interfaces and the other had instantiatable
classes.
You should be able to snoop around in the COM support dlls you've
generated if you have the .NET tools around. Run ILDASM on them
and try to find where the instantiatable classes are.
Hope this helps,
Brian Lloyd brian at zope.com
V.P. Engineering 540.361.1716
Zope Corporation http://www.zope.com
More information about the PythonDotNet
mailing list