Object Reference Issue

I'm stumped. Everything was working about three weeks ago. Now, I'm getting a strange error.

I have a structure (VertexPositionColorColorTexture) that contains several Vector2 structure variables. The Vector2 structure is simply a float for x and y.

When running in Visual Studio, everything is fine.

When running in Xamarin, I get a "reference not set to an instance of an object" error.

However, if I hover over the variable in the Xamarin IDE, it shows the object has a value.

I've tried to simplify it down as much as possible and you can see below that I'm even re-initializing before setting the value.

image

Any thoughts on why this is happening?

Posts

  • mhutchmhutch USMember, Xamarin Team Xamurai

    What are the exception details?

  • TimTryzbiakTimTryzbiak USMember

    Hi Michael,

    The HRESULT I'm getting back is a "Pointer that is not valid". However, since I'm creating a new Vector2, I wouldn't think that was possible.

    I've included 2 images:
    1. Simple code
    2. Details from the exception

    Thanks

    image

    image

    Stack Trace:
    System.NullReferenceException: Object reference not set to an instance of an object

    at ootii.Firefly.Graphics.Vertices.VertexPositionColorColorTexture.SetTextureUV (single,single) [0x0000d] in c:\Development\com\ootii\Firefly\Graphics\Vertices\VertexPositionColorColorTexture.cs:46

    at ootii.Firefly.Graphics.Canvas.CanvasItem.Set (single,single,single,single,Microsoft.Xna.Framework.Matrix,ootii.Firefly.Graphics.Images.ImageData,single,ootii.Firefly.Graphics.Materials.BaseMaterial) [0x0021b] in c:\Development\com\ootii\Firefly\Graphics\Canvas\CanvasItem.cs:156

    at ootii.Firefly.Graphics.Canvas.Canvas.StageQueueObjects () [0x002dd] in c:\Development\com\ootii\Firefly\Graphics\Canvas\Canvas.cs:355

    at ootii.Firefly.Base.BaseGame.PreFrameDraw (ootii.Firefly.Base.GameState) [0x0001b] in c:\Development\com\ootii\Firefly\Base\BaseGame.cs:420

    at ootii.Firefly.Base.BaseGame.Draw (Microsoft.Xna.Framework.GameTime) [0x0000f] in c:\Development\com\ootii\Firefly\Base\BaseGame.cs:386

    at Microsoft.Xna.Framework.Game.DoDraw (Microsoft.Xna.Framework.GameTime) [0x00028] in c:\Development\com\MonoGame\MonoGame-develop_04292013\MonoGame.Framework\Game.cs:688

    at Microsoft.Xna.Framework.Game.Tick () [0x001d4] in c:\Development\com\MonoGame\MonoGame-develop_04292013\MonoGame.Framework\Game.cs:525

    at Microsoft.Xna.Framework.AndroidGameWindow.OnUpdateFrame (OpenTK.FrameEventArgs) [0x0005e] in c:\Development\com\MonoGame\MonoGame-develop_04292013\MonoGame.Framework\Android\AndroidGameWindow.cs:253

    at OpenTK.Platform.Android.AndroidGameView.UpdateFrameInternal (OpenTK.FrameEventArgs) [0x0000c] in /Users/builder/data/lanes/monodroid-lion-bs1/0cc7ae3b/source/monodroid/src/OpenGLES/Android/AndroidGameView.cs:295

    at OpenTK.Platform.Android.AndroidGameView.RunIteration (System.Threading.CancellationToken) [0x00084] in /Users/builder/data/lanes/monodroid-lion-bs1/0cc7ae3b/source/monodroid/src/OpenGLES/Android/AndroidGameView.cs:451

    at OpenTK.Platform.Android.AndroidGameView/c__AnonStorey0.<>m__3 (object) [0x00000] in /Users/builder/data/lanes/monodroid-lion-bs1/0cc7ae3b/source/monodroid/src/OpenGLES/Android/AndroidGameView.cs:359

    at Android.App.SyncContext/c__AnonStorey29.<>m__14 () [0x00000] in /Users/builder/data/lanes/monodroid-lion-bs1/0cc7ae3b/source/monodroid/src/Mono.Android/src/Android.App/SyncContext.cs:37

    at Java.Lang.Thread/RunnableImplementor.Run () [0x0000b] in /Users/builder/data/lanes/monodroid-lion-bs1/0cc7ae3b/source/monodroid/src/Mono.Android/src/Java.Lang/Thread.cs:32

    at Java.Lang.IRunnableInvoker.n_Run (intptr,intptr) [0x00008] in /Users/builder/data/lanes/monodroid-lion-bs1/0cc7ae3b/source/monodroid/src/Mono.Android/platforms/android-10/src/generated/Java.Lang.IRunnable.cs:69

    at at (wrapper dynamic-method) object.a0b64f07-516f-4a1f-9d20-55b960e89d2a (intptr,intptr)

    at

  • mhutchmhutch USMember, Xamarin Team Xamurai

    Strange, it looks like a runtime issue, the exception isn't coming from Xamarin Studio. Could you please file a bug against the Xamarin.Android debugger and attach your test case? You can mark the bug private if you want to keep your code private.

Sign In or Register to comment.