System.MissingMethodException was unhandled

Topics: Developer Forum, User Forum
Apr 8, 2012 at 4:23 PM

Hi all,

After updating FarseerPhysics from 3.2 to 3.3 I get this exception in my FlatRedBall game:

System.MissingMethodException was unhandled
  Message=Method not found: 'Boolean FarseerPhysics.Dynamics.Body.get_IsDisposed()'.
  Source=FlatRedBallSnooker
  StackTrace:
       at FlatRedBallSnooker.Game1.testAim()
       at FlatRedBallSnooker.Game1.Update(GameTime gameTime) in C:\FlatRedBallProjects\FlatRedBallSnooker\FlatRedBallSnooker\FlatRedBallSnooker\Game1.cs:line 443
       at Microsoft.Xna.Framework.Game.RunGame(Boolean useBlockingRun)
       at Microsoft.Xna.Framework.Game.Run()
       at FlatRedBallSnooker.Program.Main(String[] args) in C:\FlatRedBallProjects\FlatRedBallSnooker\FlatRedBallSnooker\FlatRedBallSnooker\Program.cs:line 15
  InnerException:

If I remove the code that throws this exception My game runs OK.

This is the code that throws this exception:

 private void testAim()
        {
            if (onRotationbar && TimeManager.SecondsSince(testShotFired) > testShotFrequency)
            {
                if (potline != null) ShapeManager.Remove(potline);
                if (potline1 != null) ShapeManager.Remove(potline1);

                TestEnabled();

                if (power == 0) power = 5;
                if (count == 0)
                {
                    for (int i = 0; i < ballred.Length; i++)
                    {
                        redBody[i].Enabled = false;
                    }
                    cueBallBody.Enabled = false;                    
                    testredBody = BodyFactory.CreateCircle(world, 20f / (2f * MeterInPixels), 1f, redBody[ident].Position);
                    testredBody.BodyType = BodyType.Dynamic;
                    testredBody.Restitution = 1f;
                    testredBody.IsBullet = true;
                    testredBody.Friction = 0.1f;
                    testredBody.LinearDamping = 1f;
                    testredBody.AngularDamping = 0.8f;
                    testredBody.CollisionCategories = Category.Cat10;
                    testredBody.CollidesWith = Category.Cat10;
                    testredBody.OnCollision += TestOnCollision;
                    testredBody.OnSeparation += TestOnSeparation;
                    testredBody.Enabled = true;

                    testcue = BodyFactory.CreateCircle(world, 20f / (2f * MeterInPixels), 1f, cueBallBody.Position);
                    testcue.BodyType = BodyType.Dynamic;
                    testcue.Enabled = false;
                    testcue.Restitution = 1f;
                    testcue.IsBullet = true;
                    testcue.Friction = 0.1f;
                    testcue.LinearDamping = 1f;
                    testcue.AngularDamping = 0.8f;
                    Vector2 testcuePosition = cueBallBody.Position;
                    testcue.Enabled = true;
                    testcue.CollisionCategories = Category.Cat10;
                    testcue.CollidesWith = Category.Cat10;

                    testcue.ApplyLinearImpulse(new Vector2((float)System.Math.Cos(rotationAngle) * (power * 6),
                    (float)System.Math.Sin(rotationAngle) * (power * 6)));
                }
                count = count + 1;

                potline = ShapeManager.AddLine();
                potline.RelativePoint1 = new Point3D(ballred[ident].X, ballred[ident].Y, 0);
                potline.RelativePoint2 = new Point3D(testredBody.Position.X - frbcorrX, testredBody.Position.Y - frbcorrY, 0);
                potline.Color = new Color(255, 0, 0, 0);
                if (!aimed) potline.Visible = false;
                if (!onRotationbar) potline.Visible = false;

                if (count > 40)
                {
                    if (testcue != null) testcue.Dispose();
                    if (testredBody != null) testredBody.Dispose();
                    field.Color = Color.Red;
                    if (potline != null) ShapeManager.Remove(potline);
                    count = 0;

                }
                if ((count1 == 0) && (testcue.IsDisposed))
                {
                    
                    testredBody1 = BodyFactory.CreateCircle(world, 20f / (2f * MeterInPixels), 1f, redBody[ident].Position);
                    testredBody1.BodyType = BodyType.Dynamic;
                    testredBody1.Restitution = 1f;
                    testredBody1.IsBullet = true;
                    testredBody1.Friction = 0.1f;
                    testredBody1.LinearDamping = 1f;
                    testredBody1.AngularDamping = 0.8f;
                    testredBody1.CollisionCategories = Category.Cat11;
                    testredBody1.CollidesWith = Category.Cat11;
                    testredBody1.OnCollision += TestOnCollision1;
                    testredBody1.OnSeparation += TestOnSeparation1;
                    testredBody1.Enabled = true;

                    testcue1 = BodyFactory.CreateCircle(world, 20f / (2f * MeterInPixels), 1f, cueBallBody.Position);
                    testcue1.BodyType = BodyType.Dynamic;
                    testcue1.Enabled = false;
                    testcue1.Restitution = 1f;
                    testcue1.IsBullet = true;
                    testcue1.Friction = 0.1f;
                    testcue1.LinearDamping = 1f;
                    testcue1.AngularDamping = 0.8f;
                    Vector2 testcue1Position = cueBallBody.Position;
                    testcue1.Enabled = true;
                    testcue1.CollisionCategories = Category.Cat11;
                    testcue1.CollidesWith = Category.Cat11;

                    testcue1.ApplyLinearImpulse(new Vector2((float)System.Math.Cos(rotationAngle) * (power * 6),
                    (float)System.Math.Sin(rotationAngle) * (power * 6)));
                }

                if (testredBody1 != null)
                {
                    count1 = count1 + 1;

                    potline1 = ShapeManager.AddLine();
                    potline1.RelativePoint1 = new Point3D(ballred[ident].X, ballred[ident].Y, 0);
                    potline1.RelativePoint2 = new Point3D(testredBody1.Position.X - frbcorrX, testredBody1.Position.Y - frbcorrY, 0);
                    potline1.Color = new Color(0, 0, 255, 0);
                    if (!aimed) potline1.Visible = false;
                    if (!onRotationbar) potline1.Visible = false;


                    if (count1 > 40)
                    {
                        if (testcue1 != null) testcue1.Dispose();
                        if (testredBody1 != null) testredBody1.Dispose();
                        field.Color = Color.Red;
                        if (potline1 != null) ShapeManager.Remove(potline1);
                        count1 = 0;
                    }
                }

                testShotFired = TimeManager.CurrentTime;
            }

        }

I hope someone can help me with this.

Thanks ,
Groover