Search code examples
c#visual-studioemgucvattach-to-process

Debugging .NET crash that does not happen within Visual Studio IDE


When I ran my C# WinForms executable outside of the Visual Studio IDE for the very first time, I received the following dialog:

"<Application> has stopped working, Windows can check online..."

So I attached to the process using Visual Studio's Attach to Process, which showed that the program had suspended within InitializeComponent() (but did not provide further clues).

I edited the application, placed a try/catch block around the aforementioned code, which allowed me to print the following MessageBox output:

As you can see, this showed that the application is not able to find a DLL it needs.

My question: Could I have achieved this result without modifying the application (that is, without the try/catch block printing out the specifics)? Could Visual Studio Attach to Process functionality guide me to the specific problem being the missing DLL? If so, how?


Solution

  • This information can be found from fusion logs, if you enable them. Fusion logs are helpful in diagnosing if an assembly load fails because of missing dependencies.

    Also, sometimes event viewer has useful information.

    https://msdn.microsoft.com/en-us/library/e74a18c4%28v=vs.110%29.aspx