PyCLR - access to .NET modules thru reflection and win32com...

Boji Yarugawa bojibo at yarwniwa.com
Sat Dec 21 15:14:38 EST 2002


Hi

I am trying to use Mark Hammond's superb win32com module to access .NET
modules.
I have a C# module which is a ComInterop module and loads .NET DLLs and
invokes on objects when requested. The generic interface takes in Object[]
for method args.

This works fine for most cases.

i.e. normally for a "normal" method:
C#:
void bar(string yadda, int badda);

I would use:
Python + Win32com:

PyCLR = win32com.Dispatch("...")
PyCLR.invoke_2(obj, "bar", ["abcd", 10])

However:

When I try to call a method with a signature like this:

void foo(string[] myargs);

I need to wrap the "myargs" as an array of arrays.
PyCLR.invoke_2(obj, "bar", [["abcd", "efgh"]])

It does NOT work. The call never gets beyond the win32com layer.
I attached the debugger to the Python process, and saw it work for "normal"
invocations, but this failed for array arg case.

However, I am able to pass arrays of arrays (lists) to Excel ranges, for
example. What am I doing wrong?

As a side note, after I wrote the layer, I came across a paper by Mark - he
has done the same, I think for access to the .NET runtime; so on a whole, a
waste of effort on my part.
Still, would like to get it to work.

Any light on this? I can post the code here, if that helps...

Regards
Chetan Gadgil
(cgjunkaddr (_at) attbi (_do-t) com)






More information about the Python-list mailing list