Search code examples
c#eyeshot

Getting object reference error on a base.Method() in release mode


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?


Solution

  • 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();
      }
    }