Use .NET dll in Python

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

I cannot find a direct solution to this anywhere. I tried using pip install *dll location* but no luck (hopes were never high). A.

I was almost completely a .NET developer, so my python knowledge is pretty poor. There must be some way to install third-party DLL packages.

+5
source share
1 answer

As a simple and easy answer for the others I tried to find.

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

Then you can use your dll with Python for .NET (impot clr) by setting the link using the AddReference method. Then you dll are ready to go! Example:

 import sys import clr sys.path.append(r"C:\Users\...") clr.AddReference("MyDll") from mynamespace import myclass x = myclass() 
+4
source

Source: https://habr.com/ru/post/1238120/


All Articles