In my development environment my application runs, then when I installed it in a client machine it is not starting, my only idea to see the reason was to show a message box with the exception:
AppDomain.CurrentDomain.UnhandledException
+= delegate(object sender, UnhandledExceptionEventArgs args)
{
var exception = (Exception) args.ExceptionObject;
MessageBox.Show("El programa se ha detenido debido a un error interno: " +
Environment.NewLine + exception.Message + exception);
Environment.Exit(1);
};
This shows the next message
Object reference not set to an instance of an object. controli.Program.Main()
I am familiar with that exception but not at Program.cs
file, how is it possible that this fails in a client machine? And not in mine.
Finally I know about remote debugging but the problem is that it only allows to connect to a process has already started, and my application throws when loading
Do you have any suggestions or tools that I can use
If it is possible to alter the application, you can set a named event, and wait for it. Then, create another application that sets that event. Then do the following:
After that your application will continue executing and you will be able to debug it.
If you are unfammiliar with named events, have a look at this tutorial.
You can use a free library like nlog to add logging to the application. This will help you with the flow. You can also add try catch
blocks and log the exceptions along with the stack at that point.
Note that even if your application uses multiple threads, nlog supports logging each one separately.