System.OverflowException when re-navigating to page

Nov 30, 2010 at 3:07 PM


This question pertains to the use of the physics helper library version on WP7.

I am getting System.OverflowException when re-navigating to a page containing at least one physics object.

Here's the stack trace:

{"Value was either too large or too small for an Int32."}

   at System.Convert.ToInt32(Double value)
   at System.Convert.ToInt32(Single value)
   at Spritehand.FarseerHelper.PhysicsSprite.Update()
   at Spritehand.FarseerHelper.PhysicsControllerMain.UpdateDraw()
   at Spritehand.FarseerHelper.PhysicsControllerMain.CompositionTarget_Rendering(Object sender, EventArgs e)
   at System.Windows.Media.CompositionTarget.OnRendering(Object sender, RenderingEventArgs e)
   at MS.Internal.JoltHelper.RaiseEvent(IntPtr target, UInt32 eventId, IntPtr coreEventArgs, UInt32 eventArgsTypeIndex)

Repro steps:

1) Set up MainPage.xaml with a button which will navigate to another page on the Click event.

2) On the second page, set up a physics controller and at least one physics object using behaviors provided by the helper.

3) Run the app.

4) At the main page, click/touch on the button. This navigates to the second page.  Physics object should render fine.

5) Hit the Back key.

6) Main page appears. Now, click/touch on the button again.

7) Second page appears briefly and then immediately exits with System.OverflowException as described above.


Has anyone else experienced this?


Nov 30, 2010 at 6:17 PM

It's solved.

It turns out I forgot to explicitly set the width and height on the main Canvas container.

All is fine now. :)