How to use a C# dll in IronPython

import clr    
clr.AddReferenceToFileAndPath(r"C:\Folder\Subfolder\file.dll")

is the simplest way as proposed by Jeff in the comments. This also works:

import clr
import sys

sys.path.append(r"C:\Folder\Subfolder")  # path of dll
clr.AddReference ("Ipytest.dll") # the dll
import TestNamspace  # import namespace from Ipytest.dll

Leave a Comment