简体   繁体   中英

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!!!

User clr.AddReferenceToFileAndPath and double your backslashes. So:

import clr
clr.AddReferenceToFileAndPath('C:\\Desktop\\DLLTest.dll')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM