I believe [] syntax is meant for generics.  To create string s = System.String(“some string”) should work.


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

Anyone getting the following problem when running the current version of <>  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
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
  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.


Python.NET mailing list -