Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to load DLL using Iron python?

I wrote the simplest DLL using C# and copied it to the desktop. Now I wanted to load the DLL in order to see that I can use the API but I get some errors:

the code I used: (edited after looking at some questions here)

import clr
import sys
sys.path.Add("C:\Desktop\DLLTest.dll")
clr.AddReference("C:\Desktop\DLLTest.dll")

I get this error :

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  IOError: System.IO.IOException: Could not add reference to assembly DLLTest.dll

what is needed to be added to sys path? why? thanks!!!

like image 771
user1386966 Avatar asked Jan 13 '23 13:01

user1386966


1 Answers

User clr.AddReferenceToFileAndPath and double your backslashes. So:

import clr
clr.AddReferenceToFileAndPath('C:\\Desktop\\DLLTest.dll')
like image 159
Viktor Kerkez Avatar answered Jan 18 '23 07:01

Viktor Kerkez