0

As the title implies, when I close the window for the form, the program crashes and throws this exception.

An unhandled exception of type 'System.ObjectDisposedException' occurred in System.Windows.Forms.dll

Additional information: Cannot access a disposed object.

This the bit of code that includes the invoke.

 public void Node2Data(float[] data, float deltaT)
    {
        if (InvokeRequired)
            Invoke((Action)(() => Node2Data(data, deltaT))); // invoke itself
        else
        {
            //send node 2 data to parent quat
            parentQuat.X = data[0];
            parentQuat.Y = data[1];
            parentQuat.Z = data[2];
            parentQuat.W = data[3];

This is part of a windows form program and should close the window and return to the start when it's all said and done.

  • What is calling Node2Data? My guess is your form is subscribed to some event that calls this and never unsubscribed before it closed. Invoke would fail with object disposed once the Form was closed (disposed). – Tim Feb 19 '17 at 21:30
  • It is not Invoke() that is doing this, it is your code. You keep calling this method even though the window isn't there anymore. Don't do that. http://stackoverflow.com/a/1732361/17034 – Hans Passant Feb 19 '17 at 21:37

0 Answers0