[Python.NET] System.InvalidOperationException: Handle is not initialized

Ethan Adler ewadler at gmail.com
Fri Apr 24 20:34:10 CEST 2009

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)]
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
  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
  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.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pythondotnet/attachments/20090424/304b8ff8/attachment.htm>

More information about the PythonDotNet mailing list