Search code examples
c#mission-planner

Visual Studio unexpectedly closed when I tried to open specific files of Mission Planner at design time


I followed the instructions in Mission Planner GitHub page. However, Visual Studio failed (I mean it froze, then closed without any alerts) when I tried to open up some specific files, and based on the limited messages I got from Event Viewer, I found that it's the issue of a control called HUD, which is in the MissionPlanner.Controls project.

The message from event viewer:

the message from event viewer

Additionally, for testing purposes, I also tried to add an new HUD control to a form that doesn't have the control, and it threw a MissingMethodException, which is different from what I saw on Event Viewer. To sum up, I got different exceptions from the same file.

The error message when I tried to add a new HUD:

the error message when I tried to add a new HUD

However, after all these exceptions, the project can be built and it works fine at runtime.

I checked the versions of the dependencies for the MissionPlanner.Controls project, but I didn't notice anything wrong or unusual. Then, for the first exception, I commented out some code in the Dispose method in HUD.cs. Though the design pages that include HUDs still don't show properly, at least Visual Studio no longer closes unexpectedly.

    protected override void Dispose(bool disposing)
    {
        log.Info("HUD Dispose");

        if (opengl)
        {
            foreach (character texid in _texture)
            {
                //if (texid != null && texid.gltextureid != 0)
                //GL.DeleteTexture(texid.gltextureid);
            }

            this._texture = new character[_texture.Length];

            foreach (character texid in charDict.Values)
            {
                //if (texid.gltextureid != 0)
                //GL.DeleteTexture(texid.gltextureid);
            }
        }

        base.Dispose(disposing);
    }

As for the second exception, I thought that it might be an issue caused by a constructor, but what's weird is that there truly is a constructor that takes a Graphics instance as a parameter and it doesn't inherit from another class, so I can't think of any other possibilities that can cause this situation.

Furthermore, I have cloned this project to another laptop before I cloned it to this one, and the design time issue didn't exist, so perhaps it's the issue of laptop?

Is there anything I can do to fix this? Thanks in advance!

UPDATE

Application error:

Application Error

I just viewed the events from Application Error(I only checked the events from .NET Runtime before) and did a rough check. I found that it's basically the problem from KERNELBASE.dll.


Solution

  • Turned out it's a Visual Studio issue, so currently I have nothing to do but rolling back to version 17.8.x of Visual Studio.
    See Mission Planner issue #3306.