2

I have to create a win32 python dll file which can used in C#.Net code. And access the classes & functions present in the dll file through C#. Is there any way to create a win32 python dll?

Please help me out....

5
  • 1
    Are you trying to put Python code in a DLL and call this from C#? Commented Aug 26, 2011 at 8:27
  • For .NET, you need IronPython, not "ordinary" Python. stackoverflow.com/questions/2437306/… Commented Aug 26, 2011 at 8:40
  • Maybe you should consider using IronPython. Commented Aug 26, 2011 at 8:42
  • Yes I am trying to put Python code in a DLL and call this from C#. Commented Aug 26, 2011 at 9:03
  • Pyrex + ctypes appears to be the answer, but a COM server might be more convenient than a win32 dll. Commented Aug 26, 2011 at 13:18

3 Answers 3

1

You can compile your Python sources to a DLL with pyc.py, in the Samples directory of IronPython. However, you can't load this DLL from C# directly - you'll still need to host IronPython, but then you can reference the DLL with the IronPython engine and import from it.

Sign up to request clarification or add additional context in comments.

Comments

0

Try do some investigation about Pyrex. I'm not sure if it will solve your issue, but at least I seen that some guys was trying to get it working.

Comments

0

You don't need any DLL, you just need to load your Python sources using IronPython

2 Comments

So, how can we hide the python sources. I have to bundle it in the C# .dll. Is it possible?
Absolutely, include the source as a string resource in your assembly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.