How to handle exceptions without using try catch finally

Showing Answers 1 - 51 of 51 Answers

ajeez

  • Oct 10th, 2006
 

No,there is no way without try catch finally

ganesh

  • Oct 23rd, 2006
 

its highly imposible to handle exceptions without using try and catch.

  Was this answer useful?  Yes

eran

  • Oct 31st, 2006
 

Callbacks: Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException); AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);

  Was this answer useful?  Yes

Sudheer

  • Nov 27th, 2006
 

Another way of doing this is using Application Blocks.

U can write the code without try/catch block and yet catch them using application blocks.

Regards,

Sudheer.K

9989237627

  Was this answer useful?  Yes

Nila

  • Jan 15th, 2007
 

You will have to anticipate any possible complications, then deal with them accordingly (e.g. division by zero). This is much better if done intelligently because it uses alot less resources than exception handling would.

  Was this answer useful?  Yes

Ashish

  • Jan 30th, 2007
 

We Can handle exception without using Try/Catch Block in Global. asax file.It can be handled in Application_error event.

  Was this answer useful?  Yes

Bishwajeet

  • Oct 20th, 2011
 

Yes it is possible to handle exception without using try catch. We can implement If...Else block with GoTo Statement. It will be complex but possible.

  Was this answer useful?  Yes

testernew

  • Oct 23rd, 2011
 

use "using" keyword. Make sure that the object instance you are creating must be inherited by IDisposable interface.

Example:

public class Test:IDisposable
{
/// class methods
/// Idisposable interface method implementation
}

using(Test obj = new Test()){
// your logic here
}

  Was this answer useful?  Yes

Dadan Tiwari

  • Feb 13th, 2012
 

Define custom error mode in web.config file and redirect user to error pages

  Was this answer useful?  Yes

sudeep

  • Nov 11th, 2012
 

Yes, Without using try and cache block exception handling is possible.
By using if and else statement we can handle exception. It is the more efficient way to handle the exception.

try it!!

vpote

  • Apr 15th, 2013
 

The best way to do this would be doing the same in global.asax application_error method.

Thanks
Vijay

  Was this answer useful?  Yes

Chandrashekhar Upadhyay

  • Nov 16th, 2013
 

using (SqlConnection con = new SqlConnection())
{
try
{
con.Open();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}

  Was this answer useful?  Yes

sundar

  • Jul 17th, 2015
 

Please read the question properly. Proof read before submit the answer (Dont copy paste)
try...catch and finally blocks will be automatically added at runtime
Using (SqlConnection con = new SqlConnection())
{
con.Open();
}

  Was this answer useful?  Yes

nitesh

  • Mar 31st, 2016
 

Yes..It is possible using if else statements in your code

  Was this answer useful?  Yes

Dnayenshwar

  • Aug 1st, 2016
 

Yes, We can handle the exceptions without using Try catch block.
We can use global.asax event i.e Application_Error .

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions