Calling Python from C# - please help

Mark Hammond mhammond at skippinet.com.au
Sat Sep 14 04:19:08 EDT 2002


Syver Enstad wrote:
> loewis at informatik.hu-berlin.de (Martin v. Löwis) writes:
> 
> 
>>adila001 at yahoo.com (AdrianC) writes:
>>
>>
>>>I am using Python 2.1 and I am tring to use my Python COM component.
>>
>>>From VB6 everything is OK, but in .NET i don't know how to set the
>>>reference to my COM.
>>
>>I've never used the COM bridge in .NET, but I believe you need to
>>create a type library first.
> 
> 
> Although you don't have to make a typelibrary, your C# code will be
> nicer if you do so (else you will have to use the dispatch interface
> to work with the object).

Yes on all counts.  You should create a type library defining your 
interface, and use the .NET tlbimp.exe tool to create a standard .dll 
assembly.  Your C# code then imports this assembly and can use the 
object as a "first class" .NET object.

I have no examples of this, but I should.  I'm co-authoring a .NET book 
which is nearly out :) - 
http://www.aw.com/catalog/academic/product/1,4096,0201770180,00.html - 
Python does get a bit of a mention :)

Mark.




More information about the Python-list mailing list