Reputation: 614
I am suing CPython 2.7 and have installed Python for NET clr package. I DO NOT want to use Iron Python.
When I run the python from MING32 command line it works:
PC@User /c/Users
$ python
Python 2.7.8 (default, Jun 30 2014, 16:03:49) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import clr
>>> clr.AddReference(r"C:\Users\MasterEmulator")
<System.Reflection.RuntimeAssembly object at 0x02368F30>
Howeever if I executed th same code from python script it fails:
PC@User /c/Users
$ cat s.py
import clr
clr.AddReference(r"C:\Users\MasterEmulator")
PC@User /c/Users
$ python s.py
Traceback (most recent call last):
File "s.py", line 2, in <module>
clr.AddReference(r"C:\Users\MasterEmulator")
System.IO.FileNotFoundException: Unable to find assembly 'C:\Users\MasterEmulator'.
at Python.Runtime.CLRModule.AddReference(String name)
What am I doing wrong here?
EDIT: This script however works. Seems so problem with absolute paths...
import clr
clr.AddReference(r"../Users/MasterEmulator")
Upvotes: 0
Views: 267
Reputation: 11
How to use a C# dll in IronPython
sys.path.append(r"C:\Folder\Subfolder") # path of dll
clr.AddReference ("Ipytest.dll") # the dll
Upvotes: 1