[python-win32] Referencing SimpleCOMServer-based COM object fromVisStudio C# code?

Mark Hammond mhammond at skippinet.com.au
Fri Apr 28 14:48:05 CEST 2006


> I am trying to access my python class, implemented as a COM server,
> from my Visual Studio C# application. The problem is when I try to add
> a reference with Visual Studio, my COM object isn't listed.
>
> When I run PythonWin and use its COM Browser tool, my COM object is in
> one of the "registered categories", the Python COM server category.
>
> I based my Python code on Mark's SimpleCOMServer.py example and
> registered it, which seemed to work. It's in the registry and, as I
> said, the COM browser in PythonWin seems to know about it. But Visual
> Studio's COM browser doesn't list it and I don't know how else to
> reference it in my C# code.
>
> Mark uses SimpleCOMServer.py with a snippet of VB code, which leads me
> to believe that it is creating a fully-legal COM server. But Visual
> Studio must need something closer to a
> type library for me to be able to simply reference it in my C# project.

You need to provide a typelibrary that describes your object.  Pywin32
doesn't come with tools to automatically create typelibs from your .py code,
but it is capable of tieing your externally created typelib and your .py
implementation together.  Thus, you need something like the MSVC tools to
create it.  Check out the 'pippo' samples in the win32com\test directory
(but its still not pretty).  Check the archives of this list for some
discussions about adding better support to pywin32, incase you are
interested...

Mark



More information about the Python-win32 mailing list