[Python.NET] Using Third Party C# Libraries

Jim Hargrave jhargraveiii at comcast.net
Fri Mar 2 07:32:44 CET 2007


I installed the Python.Net for 2.0 (pre-compiles binaries) from the link 
below.  But I am unable to get this working:

 >>> import clr  # this works
 >>> clr.AddReference("System.Windows.Forms")
Traceback (most recent call last):
   File "<input>", line 1, in ?
AttributeError: AddReference

According to the readme file this is supposed to work and matches up 
with the IronPython syntax. Am I doing something wrong?

I copied the Python.Net for 2.0 binaries over my Python 2.4 install 
(overwriting my python.exe).

All sample Python.NET files worked fine - but they use the old "CLR" syntax.

Jim


angel ignacio colmenares laguado wrote:
> for Python.NET support for .NET 2.0:
> 
> 1. Download de latest source from 
> http://pythonnet.svn.sourceforge.net/viewvc/pythonnet/trunk/
> 
> 
> (you can use Tortoise SVN in win*)
> 
> 2. change in  importhook.cs :
> 
> line 25 
> static *Clr*Module clr;   with	static *clr*Module clr;
> 
> 
> line 50
> clr = new *Clr*Module("clr");     with 	    clr = new 
> *clr*Module();
> 
> line 51
> 
> Runtime.PyDict_SetItemString(dict, "clr", *clr*.pyHandle); 
> with
> Runtime.PyDict_SetItemString
> (dict, "clr", *root*.pyHandle);
> 
> 
> line 111:
> 
> Runtime.Incref(*clr*.pyHandle);
> with
> Runtime.Incref(*root*.pyHandle);
> 
> 
> line 112:
> return *clr*.pyHandle;
> 
> with
> return *root*.pyHandle;
> 
> 
> 3. Change makefile with this:
> 
> 
> ILDASM=ildasm.exe
> ILASM=/c/WINDOWS/Microsoft.NET/Framework/v2.0.50727/ilasm.exe
> CSC=/c/WINDOWS/Microsoft.NET/Framework/v2.0.50727/csc.exe
> 
> 
> all: python.exe
> 
> python.exe: Python.Runtime.dll
> 	cd src; cd console; \
> 
> 	$(CSC) -nologo -target:exe -out:../../python.exe \
>         -reference:../../Python.Runtime.dll -recurse:*.cs
> 	cd ..; cd ..;
> 
> 
> 
> Python.Runtime.dll:clr.dll
> 	cd src; cd runtime; \
> 	$(CSC) -nologo -unsafe -target:library -out:../../Python.Runtime.dll \
> 
>        -reference:clr.dll \
> /       -recurse:*.cs
> 	cd ..; cd ..;
> 
> 
> /clr.dll: 
> 	$(ILASM) -nologo -dll -quiet -output=clr.dll \
> 	./src/runtime/clrmodule.il;
> 
> 
> 
> 4. using Mingw32 (msys) execute:
> 
> makefile
> 
> 
> you get :Python.Runtime.dll, clr.dll and pyton.exe
>  ready for net 2.0
> 
> 
> 5. put Python.Runtime.dll and crl.dll in your python24 directory.
> 
> 
> 6. you can get ready binaries (Python.Runtime.dll
> , clr.dll and pyton.exe) for Net 2.0  from :
>  
> http://angel.ignacio.colmenares.googlepages.com/pythonnet
> 
> 7. Some screenshots in : 
> 
> http://angel.ignacio.colmenares.googlepages.com/pythonnet/
>  <http://angel.ignacio.colmenares.googlepages.com/pythonnet>/
> 
> 
> angel ignacio colmenares laguado
> 
> 
> ------------------------------------------------------------------------
> 
> _________________________________________________
> Python.NET mailing list - PythonDotNet at python.org
> http://mail.python.org/mailman/listinfo/pythondotnet



More information about the PythonDotNet mailing list