0

I'm using Eyeshot 12 to render a 3D Model for my app. The model works fine in debug mode, but throws an object reference error if I try to zoom in on the model using the mouse wheel in release mode. This is my model so far (using try-catch to stop the app from crashing suddenly):

public class Model3D : devDept.Eyeshot.Model
{
  protected override void OnMouseWheel(MouseWheelEventArgs e)
  {
    try
    {
      base.OnMouseWheel(e);
    }
    catch (Exception ex)
    {
      MessageBox.Show(ex.Message);
    }
  }
}

The error is this:

Object reference not set to an instance of an object

What can I do to fix this problem?

Jeremy Thompson
  • 61,933
  • 36
  • 195
  • 321
Gudarzi
  • 486
  • 3
  • 7
  • 22

2 Answers2

0

I've come across this before when you can't instantiate, use a Nullable type or etc, and this is difficult because its a bug with the 3rd party product. Can you try if (base.GetType() == typeof(BaseClass))

Since GetType is a method of object (the core reference type) its always available, regardless of whether the derived object has been instantiated or not.

Jeremy Thompson
  • 61,933
  • 36
  • 195
  • 321
0

I didn't find out what was causing the error, but I fixed it by overriding OnMouseWheel and writing my own logic, like this:

public class Model3D : devDept.Eyeshot.Model
{
  protected override void OnMouseWheel(MouseWheelEventArgs e)
  {
    ZoomCamera(new System.Drawing.Point((int)e.GetPosition(this).X, (int)e.GetPosition(this).Y), e.Delta, false);
    Invalidate();
  }
}
Gudarzi
  • 486
  • 3
  • 7
  • 22