Python for .NET "unable to find assembly" error

Annie picture Annie · Nov 6, 2012 · Viewed 18.3k times · Source

I'm using CPython and I have a C# dll. I'm trying to use Python for .NET to make them talk. I can't use IronPython because I need to integrate this into an existing CPython system.

I'm completely new to Python for .NET, and I actually have very little experience with Python and no experience with C#. So please forgive me if my question seems very basic.

I'm using Python 2.7.3, and I downloaded pythonnet-2.0-alpha2-clr2.0_131_py27_UCS2 and unzipped it into a folder named pyfornet_test, which also contains the dll I'm trying to use (called DotNet4Class.dll)

Then I run this:

import sys

import os

import clr

sys.path.append(r"C:\pyfornet_test")

clr.AddReference("DotNet4Class.dll")

Which gives me this error:

System.IO.FileNotFoundException: Unable to find assembly 'DotNet4Class.dll'.
   at Python.Runtime.CLRModule.AddReference(String name) in C:\Users\Barton\Documents\Visual Studio 2008\Projects\PyShar
p\trunk\pythonnet\src\runtime\moduleobject.cs:line 375

Any advice would be much appreciated. Thank you!

Answer

Prakash Nirala picture Prakash Nirala · Apr 24, 2013

Try this (without extension .dll):

clr.AddReference(r"C:\pyfornet_test\DotNet4Class")