System.InvalidOperationException: Handle is not initialized

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

System.InvalidOperationException: Handle is not initialized

Ethan Adler
Anyone getting the following problem when running the current version of python.net with python2.6?

C:\Documents and Settings\ethan>python
Python 2.6.2 (r262:71605, Apr 14 2009, 22:40:02) [MSC v.1500 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import clr
>>> from System import String
>>> s = String[str]("a")

Unhandled Exception: System.InvalidOperationException: Handle is not initialized
.
  at System.Runtime.InteropServices.GCHandle.FromIntPtr(IntPtr value)
  at System.Runtime.InteropServices.GCHandle.op_Explicit(IntPtr value)
  at Python.Runtime.ManagedType.GetManagedObject(IntPtr ob)
  at Python.Runtime.Runtime.PythonArgsToTypeArray(IntPtr arg, Boolean mangleObj
ects)
  at Python.Runtime.ClassObject.type_subscript(IntPtr idx)
  at Python.Runtime.MetaType.mp_subscript(IntPtr tp, IntPtr idx)

If I try s = String("a") without the [str], it doesn't even give an error, it just quits.

I spent a few minutes looking through the archives before posting, but I did not search exhaustively, so if this is a redundant post, I apologize.

thanks,
-Ethan

_________________________________________________
Python.NET mailing list - [hidden email]
http://mail.python.org/mailman/listinfo/pythondotnet
Reply | Threaded
Open this post in threaded view
|

Re: System.InvalidOperationException: Handle is notinitialized

Maksim Kozyarchuk-2
Re: [Python.NET] System.InvalidOperationException: Handle is notinitialized Ethan,
    I believe [] syntax is meant for generics.  To create string s = System.String(“some string”) should work.

Maksim


On 4/24/09 2:34 PM, "Ethan Adler" <[hidden email]> wrote:

Anyone getting the following problem when running the current version of python.net <http://python.net>  with python2.6?

C:\Documents and Settings\ethan>python
Python 2.6.2 (r262:71605, Apr 14 2009, 22:40:02) [MSC v.1500 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import clr
>>> from System import String
>>> s = String[str]("a")

Unhandled Exception: System.InvalidOperationException: Handle is not initialized
.
  at System.Runtime.InteropServices.GCHandle.FromIntPtr(IntPtr value)
  at System.Runtime.InteropServices.GCHandle.op_Explicit(IntPtr value)
  at Python.Runtime.ManagedType.GetManagedObject(IntPtr ob)
  at Python.Runtime.Runtime.PythonArgsToTypeArray(IntPtr arg, Boolean mangleObj
ects)
  at Python.Runtime.ClassObject.type_subscript(IntPtr idx)
  at Python.Runtime.MetaType.mp_subscript(IntPtr tp, IntPtr idx)

If I try s = String("a") without the [str], it doesn't even give an error, it just quits.

I spent a few minutes looking through the archives before posting, but I did not search exhaustively, so if this is a redundant post, I apologize.

thanks,
-Ethan


_________________________________________________
Python.NET mailing list - [hidden email]
http://mail.python.org/mailman/listinfo/pythondotnet


_________________________________________________
Python.NET mailing list - [hidden email]
http://mail.python.org/mailman/listinfo/pythondotnet
Reply | Threaded
Open this post in threaded view
|

Re: System.InvalidOperationException: Handle is notinitialized

Ethan Adler
Maksim,

Thanks for you reply. Yes, I have tried that and it also crashes (without spitting out any errors) when I do that as well.

output:

-------------Start copy from console--------------
>>> import clr
>>> s = System.String("some string")

H:\>
-------------End copy from console--------------

I think the problem has to do with the fact that python.net is optimized for python2.5, but I am trying to use it with 2.6. Is anyone using python.net with Python 2.6. If so, can you email me any changes you made to the python.net code before compiling, and a precompiled dll to check against?

thanks,
-Ethan

On Fri, Apr 24, 2009 at 2:33 PM, Maksim Kozyarchuk <[hidden email]> wrote:
Ethan,
    I believe [] syntax is meant for generics.  To create string s = System.String(“some string”) should work.

Maksim


On 4/24/09 2:34 PM, "Ethan Adler" <[hidden email]> wrote:

Anyone getting the following problem when running the current version of python.net <http://python.net>  with python2.6?


C:\Documents and Settings\ethan>python
Python 2.6.2 (r262:71605, Apr 14 2009, 22:40:02) [MSC v.1500 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import clr
>>> from System import String
>>> s = String[str]("a")

Unhandled Exception: System.InvalidOperationException: Handle is not initialized
.
  at System.Runtime.InteropServices.GCHandle.FromIntPtr(IntPtr value)
  at System.Runtime.InteropServices.GCHandle.op_Explicit(IntPtr value)
  at Python.Runtime.ManagedType.GetManagedObject(IntPtr ob)
  at Python.Runtime.Runtime.PythonArgsToTypeArray(IntPtr arg, Boolean mangleObj
ects)
  at Python.Runtime.ClassObject.type_subscript(IntPtr idx)
  at Python.Runtime.MetaType.mp_subscript(IntPtr tp, IntPtr idx)

If I try s = String("a") without the [str], it doesn't even give an error, it just quits.

I spent a few minutes looking through the archives before posting, but I did not search exhaustively, so if this is a redundant post, I apologize.

thanks,
-Ethan


_________________________________________________
Python.NET mailing list - [hidden email]
http://mail.python.org/mailman/listinfo/pythondotnet



_________________________________________________
Python.NET mailing list - [hidden email]
http://mail.python.org/mailman/listinfo/pythondotnet