From khg at power21.co.kr Thu Feb 5 10:52:35 2015 From: khg at power21.co.kr (=?EUC-KR?B?sejH2LHi?=) Date: Thu, 05 Feb 2015 18:52:35 +0900 Subject: [Python.NET] [Python for .NET] question: How to correctly clean up MemoryStream object In-Reply-To: <54D33C9F.4040806@power21.co.kr> References: <54D33C9F.4040806@power21.co.kr> Message-ID: <54D33D63.9050908@power21.co.kr> Hi, I have a MemoryStream created from Python (3.4) *memory_stream = MemoryStream(data_size)* and pass it to a C# library function to get data. *self.the_library.Read(memory_stream)* This definitely works. The problem is, python.exe's memory usage increases over time. Calling *memory_stream.Dispose()* and *memory_stream.Close()* doesn't help. What am I missing? Thanks in advance. -------------- next part -------------- An HTML attachment was scrubbed... URL: From cameron.hayne at introspect.ca Sat Feb 21 00:21:49 2015 From: cameron.hayne at introspect.ca (Cameron Hayne) Date: Fri, 20 Feb 2015 18:21:49 -0500 Subject: [Python.NET] avoiding runtime error R6034 Message-ID: I?ve started using the version of PythonDotNet from https://github.com/renshawbay/pythonnet to call my Python modules from C#. I encountered the Microsoft runtime error R6034 which (according to ) is caused by extra copies of the file "msvcr90.dll? in folders on the Windows execution PATH. I worked around this problem by calling the following function in my initialization code. def cleanWindowsPathOfCRuntimeDll(): """ This function changes the Windows execution PATH environment variable so as to exclude any folders that contain the file "msvcr90.dll". Apparently the existence of this file in the PATH causes runtime error R6034 when using embedded Python. See: http://stackoverflow.com/questions/14552348/runtime-error-r6034-in-embedded-python-application """ folderPaths = os.environ['path'].split(';') toExclude = list() for folderPath in folderPaths: if "msvcr90.dll" in map((lambda x:x.lower()), os.listdir(folderPath)): toExclude.append(folderPath) debugMsg(0, "excluding folder '%s' from PATH" % folderPath) os.environ['path'] = ';'.join([x for x in folderPaths if x not in toExclude]) # ?????????????????????????????????????? -- Cameron Hayne cameron.hayne at introspect.ca From aleksberland at gmail.com Sun Feb 22 21:22:31 2015 From: aleksberland at gmail.com (Aleks Berland) Date: Sun, 22 Feb 2015 15:22:31 -0500 Subject: [Python.NET] (no subject) Message-ID: Hi All, I'm new to the list and to Python.NET I am running the latest from Git, on Mono in Ubuntu 14.04. I am working with NHibernate Database Configuration code, I am experiencing problems trying to explicitly state generic parameter (NHSearch) so the C# strong type syntax make it possible infer from NHSearch.Instance. The offending line in pythonnet is: db_adapter = DatabaseAdapter.Configure.DatabaseConfiguration(conn_sql).SearchProvider[NHSearch](NHSearch.Instance) And I get this back: Unhandled Exception: System.ArgumentException: GCHandle value cannot be zero at System.Runtime.InteropServices.GCHandle.op_Explicit (IntPtr value) [0x00000] in :0 at Python.Runtime.ManagedType.GetManagedObject (IntPtr ob) [0x00000] in :0 at Python.Runtime.Runtime.PythonArgsToTypeArray (IntPtr arg, Boolean mangleObjects) [0x00000] in :0 at Python.Runtime.MethodBinding.tp_call (IntPtr ob, IntPtr args, IntPtr kw) [0x00000] in :0 at (wrapper native-to-managed) Python.Runtime.MethodBinding:tp_call (intptr,intptr,intptr) at (wrapper managed-to-native) Python.Runtime.Runtime:Py_Main (int,string[]) at Python.Runtime.PythonConsole.Main (System.String[] args) [0x00000] in :0 [ERROR] FATAL UNHANDLED EXCEPTION: System.ArgumentException: GCHandle value cannot be zero at System.Runtime.InteropServices.GCHandle.op_Explicit (IntPtr value) [0x00000] in :0 at Python.Runtime.ManagedType.GetManagedObject (IntPtr ob) [0x00000] in :0 at Python.Runtime.Runtime.PythonArgsToTypeArray (IntPtr arg, Boolean mangleObjects) [0x00000] in :0 at Python.Runtime.MethodBinding.tp_call (IntPtr ob, IntPtr args, IntPtr kw) [0x00000] in :0 at (wrapper native-to-managed) Python.Runtime.MethodBinding:tp_call (intptr,intptr,intptr) at (wrapper managed-to-native) Python.Runtime.Runtime:Py_Main (int,string[]) at Python.Runtime.PythonConsole.Main (System.String[] args) [0x00000] in :0 Not sure how/where to start to debug this. Any tips would be helpful! I would be happy to give more details if needed of course, but I am not sure what will help at this stage, so let me know. Regards, - Aleks -------------- next part -------------- An HTML attachment was scrubbed... URL: