We can't tell you - there could be many reasons such as a form closing / form closed handler that expects something to be available which has been disposed.
But what I suspect is that "My Windows From project debugs correctly" does not mean what you think it means: compiling is not debugging. Your project clearly doesn't "debug correctly" because it is throwing a null reference exception...
Think of development as writing an email: compiling is the process of making sure that the message is written in the right language: English words, not German for example, and that they are in the right order.
Debugging is the process of making sure that the message means what you intended it to.
This email will compile:
Quote:
Oi! Send me some stuff!
And so will this:
Quote:
Hi Jane! Thanks for the call this morning, I'd like to confirm an order for 8 off your part number 45422, 6 off your partnumber 87865, and 1 off your part number 12553. My account number is 546223, my purchase order number is 1144, and if you could dispatch that via DHL 24 hour that would be great, as I need them here for start of play Friday.
Best regards,
Joe Smith, MyCompany Ltd.
But only the second debugs correctly and gets you the good you want!
Use the actual debugger - when the exception occurs, it should stop on the line that caused it and allow you to look at the variables and work out which one is null. From that, you should be able to find out why it is null. But that isn't something we can do for you - we don;t have your code, and can't run it under the same circumstances if we did.
And to be honest, using Application.Restart to log a user out is just pure laziness...