[Python.NET] [ pythonnet-Bugs-3293169 ] clr.AddReference fails when assembly is built with .NET 4.0

Barton barton at BCDesignsWell.com
Mon Feb 6 06:21:40 CET 2012


This is some of the best info distributed to date concerning compiling 
pythondotnet for .NET 4

On 5/3/2011 1:04 AM, SourceForge.net wrote:
> Bugs item #3293169, was opened at 2011-04-26 08:30
> Message generated for change (Comment added) made by barton_c
> You can respond by visiting:
> https://sourceforge.net/tracker/?func=detail&atid=823891&aid=3293169&group_id=162464
>
> Please note that this message will contain a full copy of the comment thread,
> including the initial issue submission, for this request,
> not just the latest update.
> Category: Interface (example)
> Group: None
> Status: Closed
> Resolution: None
> Priority: 5
> Private: No
> Submitted By: Guillaume (gdumont)
> Assigned to: Nobody/Anonymous (nobody)
> Summary: clr.AddReference fails when assembly is built with .NET 4.0
>
> Initial Comment:
> Hi,
>
> I am not sure if it is a bug or an incompatibility between the CLR versions but here it is:
>
> I can successfully load an assembly built with version 2.0, 3.0 and 3.5 but it fails to load with 4.0. I always get a file not found exception
>
> File "<stdin>", line 1, in<module>
> System.IO.FileNotFoundException: Unable to find assembly 'MyPythonAssemby'.
>     at Python.Runtime.CLRModule.AddReference(String name) in H:\Documents\Visual
> Studio 2008\Projects\PySharp\trunk\pythonnet\src\runtime\moduleobject.cs:line 375
>
> Does python for .NET support .NET 4.0?
>
> Thanks
>
>
> ----------------------------------------------------------------------
>
>> Comment By: Barton Cline (barton_c)
> Date: 2011-05-03 01:04
>
> Message:
>
> Here is how oleksii got VS2010 and .NET 4.0 working:
>
> 1. Get the sources (tarball from sourceforge or directly from SVN)
> 2. Open the pythonnet.sln with VS2010 and convert to 2010 format (will
> happen automagically)
> 3. Change the target framework to 4. Follow the following step for EACH
> project
>      3.1. Right-click on the project name and select "Properties"
>      3.2. Select the "Application" tab on the left (if not selected yet)
>      3.3. Change the "Target framework" to ".NET Framework 4"
> 4. Open the clrmodule.il and change the lines with the version number in
> the following piece of code
>
> .assembly extern mscorlib { .publickeytoken = (B7 7A 5C 56 19 34 E0 89 )
> .ver 2:0:0:0 }
>
> to have
>
> .ver 4:0:0:0
>
> 5. Open the buildclrmodule.bat and change the
>
> %windir%\Microsoft.NET\Framework\v2.0.50727\ilasm /nologo /quiet /dll
> %ILASM_EXTRA_ARGS% /include=%INCLUDE_PATH% /output=%OUTPUT_PATH%
> %INPUT_PATH%
>
> to
>
> %windir%\Microsoft.NET\Framework\v4.0.30319\ilasm /nologo /quiet /dll
> %ILASM_EXTRA_ARGS% /include=%INCLUDE_PATH% /output=%OUTPUT_PATH%
> %INPUT_PATH%
>
> 5. Recompile the whole solution, ignore the deprecation warnings.
>
> Now you have all necessary files under the pythonnet folder where you have
> the sources. You need clr.pyd, python.exe and Python.Runtime.dll.
>
> ----------------------------------------------------------------------
>
> Comment By: Guillaume (gdumont)
> Date: 2011-04-26 11:02
>
> Message:
> Ok,
>
> After recompiling with vs2010 and targeting .NET 4.0 my assembly loads
> fine. So I closed the ticket.
>
> ----------------------------------------------------------------------
>
> You can respond by visiting:
> https://sourceforge.net/tracker/?func=detail&atid=823891&aid=3293169&group_id=162464
>


More information about the PythonDotNet mailing list