[IronPython] XNA and how to specify the type arguments explicitly

Richard Steventon steventon at gmail.com
Tue Feb 2 16:51:20 CET 2010

Okay, so problem #2.... calling the correct version of the interface
(I think this is the problem?), since I am getting a "violates the
constraint of type 'T'" error.

I set up a XNA VertexBuffer using:
        l = Array.CreateInstance(VertexPositionColor,6)
        self.vertices = l

        self.VertexBuffer = VertexBuffer(self.graphics.GraphicsDevice, \
            len(self.vertices) * VertexPositionColor.SizeInBytes, \

And I get:
ValueError: GenericArguments[0],
'Microsoft.Xna.Framework.Graphics.VertexPositionColor[]', on 'Void
SetData[T](Int32, T[], Int32, Int32, Int32)' violates the constraint
of type 'T'.

The documentation for the VertexBuffer.SetData method can be found here:

The methods are:
  VertexBuffer.SetData (Int32, T[], Int32, Int32, Int32)
  VertexBuffer.SetData (T[])	
  VertexBuffer.SetData (T[], Int32, Int32)	

This works fine in C# with a List of VertexPositionColor objects, so I
assume that Array in IronPython is the equivalent ?  So why does it
not work ?

More information about the Ironpython-users mailing list