using c# method from python

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

using c# method from python

munawwarah Chamroo
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
 

_________________________________________________
Python.NET mailing list - [hidden email]
http://mail.python.org/mailman/listinfo/pythondotnet
Reply | Threaded
Open this post in threaded view
|

Re: using c# method from python

Tribble, Brett

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=[hidden email] [mailto:pythondotnet-bounces+btribble=[hidden email]] On Behalf Of munawwarah Chamroo
Sent: Thursday, February 18, 2010 1:34 AM
To: [hidden email]
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

 


_________________________________________________
Python.NET mailing list - [hidden email]
http://mail.python.org/mailman/listinfo/pythondotnet