[Python.NET] This assembly is built by a runtime newer than the currently loaded runtime

David Hirschfeld david.hirschfeld at gazprom-mt.com
Tue Aug 17 10:04:56 CEST 2010


I needed to access .NET dlls compiled for .NET4 and also ran into the 
System.BadImageFormatException error.

I opened PythonDotNET in VS2010 and it compiled fine with only a couple of 
errors about System.Security.Permissions.SecurityAction.RequestMinimum being 
obsolete. Unfortunately when I tried to import clr I got the following error:

SystemError: dynamic module not initialized properly

Looking further into it I found that in buildclrmodule.bat lines 33 & 66
referenced the .NET2 idalsm.exe:

%windir%\Microsoft.NET\Framework\v2.0.50727\ilasm /nologo /quiet /dll 
%ILASM_EXTRA_ARGS% /include=%INCLUDE_PATH% /output=%OUTPUT_PATH% %INPUT_PATH%

I changed this to reference the .NET4 version:

%windir%\Microsoft.NET\Framework\v4.0.30319\ilasm /nologo /quiet /dll 
%ILASM_EXTRA_ARGS% /include=%INCLUDE_PATH% /output=%OUTPUT_PATH% %INPUT_PATH%

...and everything works perfectly!

HTH,
Dave


-----Original Message-----
From: Brandon Craig Rhodes 
Sent: 28 May 2010 21:36
To: Dave Hirschfeld
Cc: pythondotnet at python.org
Subject: Re: [Python.NET] how can I build an assembly I can AddReference()?

Brandon Craig Rhodes <brandon at rhodesmill.org> writes:

> System.BadImageFormatException: This assembly is built by a runtime newer 
> than the currently loaded runtime and cannot be loaded. (Exception from 
> HRESULT: 0x8013101B)
>    at System.Reflection.Assembly.nLoadFile(String path, Evidence evidence)
>    at System.Reflection.Assembly.LoadFile(String path)

This afternoon I uninstalled Visual Studio 2010 from my laptop and
re-installed Visual Studio 2008, then rebuilt "Brandon.dll", in the
hopes that 2010 was simply too recent a version of Studio to be using
with the c:\python26 from the python.org page.  Sadly, I was wrong; I
still get the above error when trying to import the DLL.


The information transmitted is the property of Gazprom Marketing & Trading Ltd and is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Statements and opinions expressed in this e-mail may not represent those of the company. Any review, retransmission, dissemination and other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender immediately and delete the material from any computer. 

Registered office: Gazprom Marketing & Trading Ltd, Gazprom House, 60 Marina Place, Hampton Wick, Kingston upon Thames, KT1 4BH. Registered in England No. 3768267




More information about the PythonDotNet mailing list