PyCLR - access to .NET modules thru reflection and win32com...
Mark Hammond
mhammond at skippinet.com.au
Sat Dec 21 17:27:02 EST 2002
Boji Yarugawa wrote:
> 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.
The COM interop layes did give me a bit of a hard time with
Reflection::Emit, and had to hack around a number of similar problems.
Note that the sources for this compiler are in the win32all CVS
repository - look at the "CORGlue" directory.
Mark.
More information about the Python-list
mailing list