Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to import COM into Ironpython?

In Cpython, I can use win32com.

But, in ironpython, I didn't know how to import it.

Because, in .net, one always use Visual Studio to interop the COM and to use it.

like image 893
Begtostudy Avatar asked Aug 19 '10 00:08

Begtostudy


People also ask

How do I import modules into IronPython?

If you have installed IronPython from NuGet packages and you want modules from the CPython Standard Library then the best way to do it is by installing the IronPython. StdLib NuGet package which is from the same authors of IronPython .

Can IronPython use Python libraries?

IronPython is an open-source implementation of the Python programming language which is tightly integrated with . NET. IronPython can use . NET and Python libraries, and other .

Can I use NumPy in IronPython?

This means NumPy library is not supported by IronPython.

What is the difference between IronPython and Python?

Python is Python, the only difference is that IronPython was designed to run on the CLR (. NET Framework), and as such, can inter-operate and consume . NET assemblies written in other .


1 Answers

You should be able to create an IDispatch object using:

from System import Type, Activator
Activator.CreateInstance(Type.GetTypeFromProgID(com_type_name))

This is equivalent to win32com.client.Dispatch(com_type_name).

If there's a type lib you should be able to do:

import clr
import System
typelib = clr.LoadTypeLibrary(System.Guid("00020905-0000-0000-C000-000000000046"))
word = typelib.Word.Application()

I don't know what that's equivalent to. I'm not much of an expert on this but I took those from IronPython's cominterop_util which is used in the tests. There's more stuff in the IronPython\Tests\interop\com directory which might be useful.

like image 91
Dino Viehland Avatar answered Oct 18 '22 06:10

Dino Viehland