[Python.NET] using c# method from python

Tribble, Brett btribble at ea.com
Thu Feb 18 20:22:27 CET 2010


Depending on how you're code works in C#, the way you access it from Python may vary, but the basic approach is:

Compile your code as a .dll assembly, then from Python do:

import clr  # Imports the pythonnet clr stuff
clr.AddReference("myAssembly.dll")
myObjectHandle = myAssembly.myClass()
myObjectHandle.bar()



From: pythondotnet-bounces+btribble=ea.com at python.org [mailto:pythondotnet-bounces+btribble=ea.com at python.org] On Behalf Of munawwarah Chamroo
Sent: Thursday, February 18, 2010 1:34 AM
To: pythondotnet at python.org
Subject: [Python.NET] using c# method from python

Hi,
I am currently developing an application where i need to call some c# methods from my python code.
I want to know if this is possible to do using pythonnet and how to do it.

for example i have a c# class foo and in foo i have a method bar()
Now i need to call method bar() in my python code.
How should i do this.

Please help

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pythondotnet/attachments/20100218/ca752a05/attachment.htm>


More information about the PythonDotNet mailing list