Stinkidog Stinkidog - 5 months ago 39
Python Question

Use .NET dll in Python

I've developed a dll in visual studio that I'd now like to use in Python using the standard IDLE.

I cannot seem to find a straightforward solution to this anywhere. I've tried using

pip install *dll location*
, but to no luck (hopes were never high).

I've pretty much solely been a .NET developer so my knowledge of python is pretty poor. There must be some way to install third party dll packages.


Just as a plain and simple answer for others which I was struggling to find.

The dll location needs to be added to the path variable. This can be done simply by importing sys, and invoking the method shown (the path should not include the dll file).

You can then use your dll with Python for .NET (impot clr), by setting up the reference with the AddReference method. Then you're dll is ready to go! An example:

import sys
import clr



from mynamespace import myclass

x = myclass()