2

I am trying to call existing C# dll from Python. I tried both Python for .NET and Iron Python. I put dll (LogAccess.dll) just under the Python root. In the case of Python for .NET, just under the Python27 directory. In the case of IronPython, just under th IPy27.

import sys
import clr
clr.AddReference("LogAccess")
from LogAccess import LogAccess

at this point, error occurs. This is the same situation in Python for .NET and IronPython.

Traceback (most recent call last): File "Untitled", line 4 clr.AddReference('LogAccesss') FileNotFoundException: Unable to find assembly 'LogAccesss'. \u5834\u6240 Python.Runtime.CLRModule.AddReference(String name)

What is wrong ? Is there any condition to make C# dll ? Is there any rule where dll is placed ? I wnat to know relationship among modulename, namespace and main program name/

1
  • 2
    Could you try clr.AddReferenceToFileAndPath in IronPython and an absolute path to LogAccess.dll? This also ensures that the containing folder is added to lookup paths. You could also have a look at the assembly being blocked and not loaded for that reason. Commented Jan 19, 2015 at 7:23

1 Answer 1

2

First Check wether your single line

import clr

is not giving any error

if not then try putting you file inside Python27/Lib/Site-packages directory and try the same .

Or else you can specify the path

import sys
sys.path.append("yourDllPath")

then try importing the way you are doing

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.