Click here to Skip to main content
15,881,813 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hi,
I often use try catch block to catch errors but I don't know why my application crashes by displaying errors as follows.

Application has encountered a problem and needs to close

Moreover My application consists of many forms including Program.cs which is the starting class. Then Another Form (FrmMain) gets launched from Program.cs.

FrmMain opens order details and opens many forms.

So how to find the root cause for these type of errors.
Posted
Comments
Richard MacCutchan 15-May-15 11:33am    
This is difficult to answer. The only real way is to do more tests and use your debugger to try and isolate what is happening. You should also check the event logs to see if they have any information that helps.
John C Rayan 15-May-15 11:37am    
From the error it looks like you are calling unmanaged code that throws an error and you application crashes. It is really difficult to say unless we run your program.

Do what we did. Write a handler for unhandled exceptions and write the exception and trace log out to either a file or email it to yourself.

That will give you the exception, module name, and line number where it occurred.
 
Share this answer
 
Comments
KUMAR619 20-May-15 4:12am    
Can you help to create handler for undhandled exceptions
There is no one root cause for these errors - except poor programming - exception happen when there is a problem which means that some operation cannot be completed.

That operation could be as simple as a "divide by zero", or a "null reference" - or it could be buried deep in a bit of SQL that your code asks SQL Server to execute.

We can't tell. You will have to look at each one individually, and work out what kind of exception it is, and then start looking at your code to work out why.

Sorry - but we can't do that for you.
 
Share this answer
 
Comments
KUMAR619 20-May-15 7:29am    
Please take a look at this site

http://www.codeproject.com/Questions/993232/How-to-solver-Broker-Issue-using-Csharp

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900