From igorfier at hotmail.com Mon Aug 16 19:08:47 2010 From: igorfier at hotmail.com (igorfier at hotmail.com) Date: Mon, 16 Aug 2010 14:08:47 -0300 Subject: [Python.NET] embed Python in C# Message-ID: Hello all, After following some examples around the web, and some discussions in the mail list, I came into the following snippet to call a function defined in a Python script into a C# host app, as seen at ?http://mail.python.org/pipermail/pythondotnet/2007-June/000620.html?: // public static void MethodThatCallsPython() { // have to acquire the GIL to safely call back into Python!! IntPtr state = PythonEngine.AcquireLock(); PythonEngine.RunSimpleString("print 'hello'"); // done using python for now, so release the GIL... PythonEngine.ReleaseLock(state); } // Although it looks quite simple, VS2010 this throws an exception at the very first line of code: ?Attempted to read or write protected memory. This is often an indication that other memory is corrupt.? My machine runs Windows 7 64-bit, and as I read somewhere else, 64 bit OS may be a matter of concern. Does anyone know how to overcome this annoying situation?? Thank you for any help provided! Igor Fier Dept. of Physics, Condensed Matter UNESP Rio Claro ? Rio Claro-SP, Brazil -------------- next part -------------- An HTML attachment was scrubbed... URL: From blloyd at waterfrontmedia.com Mon Aug 16 19:36:21 2010 From: blloyd at waterfrontmedia.com (Brian Lloyd) Date: Mon, 16 Aug 2010 13:36:21 -0400 Subject: [Python.NET] embed Python in C# In-Reply-To: Message-ID: Python for .NET has a huge amount of carnal knowledge about the in-memory layouts of python objects etc., and I don?t know that anyone has tried to port it run with 64-bit :( On 8/16/10 1:08 PM, "igorfier at hotmail.com" wrote: > Hello all, > > After following some examples around the web, and some discussions in the mail > list, > I came into the following snippet to call a function defined in a Python > script into a C# host app, > as seen at > ?http://mail.python.org/pipermail/pythondotnet/2007-June/000620.html?: > > // > public static void MethodThatCallsPython() > { > // have to acquire the GIL to safely call back into Python!! > IntPtr state = PythonEngine.AcquireLock(); > > PythonEngine.RunSimpleString("print 'hello'"); > > // done using python for now, so release the GIL... > PythonEngine.ReleaseLock(state); > } > // > > Although it looks quite simple, VS2010 this throws an exception at the very > first line of code: > ?Attempted to read or write protected memory. This is often an indication that > other memory is corrupt.? > > My machine runs Windows 7 64-bit, and as I read somewhere else, 64 bit OS may > be a matter of concern. > Does anyone know how to overcome this annoying situation?? > > Thank you for any help provided! > > Igor Fier > Dept. of Physics, Condensed Matter > UNESP Rio Claro ? Rio Claro-SP, Brazil > > > _________________________________________________ > Python.NET mailing list - PythonDotNet at python.org > http://mail.python.org/mailman/listinfo/pythondotnet -------------------------- Brian Lloyd 540.845.2975 blloyd at everydayhealthinc.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From dave.hirschfeld at gmail.com Tue Aug 17 10:11:30 2010 From: dave.hirschfeld at gmail.com (Dave) Date: Tue, 17 Aug 2010 08:11:30 +0000 (UTC) Subject: [Python.NET] This assembly is built by a runtime newer than t he currently loaded runtime Message-ID: I needed to access .NET dlls compiled for .NET4 and ran into the error: System.BadImageFormatException: This assembly is built by a runtime newer than t he currently loaded runtime and cannot be loaded. (Exception from HRESULT: 0x801 3101B) So I attempted to recompile PythonDotNET for .NET4. In VS2010 I changed all the project targets to be .NET4 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 NB: Apologies if this appears twice - I sent it from a different account previously and don't think it made it through. From david.hirschfeld at gazprom-mt.com Tue Aug 17 10:04:56 2010 From: david.hirschfeld at gazprom-mt.com (David Hirschfeld) Date: Tue, 17 Aug 2010 08:04:56 +0000 Subject: [Python.NET] This assembly is built by a runtime newer than the currently loaded runtime In-Reply-To: <87eigvu5kq.fsf@rhodesmill.org> References: <87fx1cll9i.fsf@rhodesmill.org><87typsjhtv.fsf@rhodesmill.org> <87eigvu5kq.fsf@rhodesmill.org> Message-ID: <70AC43581AB79542A98FAC29BE37270901C439@EXMX02LONUK.Gazpromuk.intra> 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 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 From barton at BCDesignsWell.com Thu Aug 19 06:20:38 2010 From: barton at BCDesignsWell.com (Barton) Date: Wed, 18 Aug 2010 21:20:38 -0700 Subject: [Python.NET] Fwd: [ pythonnet-Patches-3044812 ] Add info parameter to the this.Bind() call Message-ID: <4C6CB116.8080701@BCDesignsWell.com> -------- Original Message -------- Subject: [ pythonnet-Patches-3044812 ] Add info parameter to the this.Bind() call Date: Sat, 14 Aug 2010 09:01:07 +0000 From: SourceForge.net To: noreply at sourceforge.net Patches item #3044812, was opened at 2010-08-14 02:01 Message generated for change (Tracker Item Submitted) made by barton_c You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=823893&aid=3044812&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: None Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: barton_c (barton_c) Assigned to: Nobody/Anonymous (nobody) Summary: Add info parameter to the this.Bind() call Initial Comment: I've added the info parameter to the call to the Binding binding = this.Bind(inst, args, kw, info) call to take advantage of Bind()'s ability to use a single MethodBase (CI or MI). ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=823893&aid=3044812&group_id=162464 -------------- next part -------------- An HTML attachment was scrubbed... URL: