Create a handler for UnhandledException
in your program so that it can help you debug the issue further and handle the exception from wherever it's been thrown (as well as other unhandled exceptions). For example
AppDomain.CurrentDomain.UnhandledException += (s,e) =>
{
Exception ex = (Exception)e.ExceptionObject;
Debug.WriteLine(ex.Message);
};