Congratulations to all the winners of April 2013, they have won INR 3400 cash and INR 20147 worth prizes !
Go to DotNetFunda.com
Twitter TwitterLinkedIn
YouTubeGoogle
 Online : 15127 |  Welcome, Guest!   Register  Login
Home > Articles > .NET Framework > Finding Handled Exceptions while debugging time

Finding Handled Exceptions while debugging time

Article posted by Kotra.Ramakrishna on 9/17/2012 | Views: 1203 | Category: .NET Framework | Level: Beginner | Points: 250 red flag


This article will help beginners. Handling exceptions finding

Introduction

This article mainly focus on how to find handled exceptions. While debugging code, we easily find unhandled exceptions. But how to find handled exceptions, please look at below steps

Prerequisite

In order to understand this article basic knowledge of C# & VS. For demo purpose i am using console application.


Creating Simple Console Application.

Go to File New-> Project, it will display window , form  that window left side templates Select Visula C#, and then come to right side select Console Application. It will create one static main method. Please refer below code

Block of code should be set style as "Code" like below.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HandlingExceptionsDebugging
{
class Program
{
static void Main(string[] args)
{

}
}
}

By default visual studio will create this code.

Now create two methods. Please refer below code.

public void UnhandledException()
{
throw new Exception("Unhandled Exception");
}

public void HandledException()
{
try
{
throw new Exception("Exception throwing");
}
catch (Exception)
{

}
}
These two methods are very simple. one is unhandled exception method, second one is handling exception.
Now go to  Main method, create Program object, and call these tow methods. Press F5 button.

Please look at below code

        static void Main(string[] args)
{
Program p = new Program();
p.HandledException();
p.UnhandledException();
Console.Read();
}

HandledException method also throwing exception but, it won't notify. Directly cursor (Exception occur) UnhandledException method.

Question is how we will find Handled Exceptions?

Go to Debug menu->Select Exception menu item it will display pop up window, Select all checkboxes below Thrown.

Please refer below screen

now run application press(F5) . now we are able to find handled exceptions also.  Cursor will stops HandledException method also.

Hope this article will useful for beginners.

If you like this article, subscribe to our RSS Feed. You can also subscribe via email to our Interview Questions, Codes and Forums section.

Page copy protected against web site content infringement by Copyscape
Found interesting? Add this to:



Please Sign In to vote for this post.

Latest Articles from Kotra.Ramakrishna

About rama krishna

Experience:2 year(s)
Home page:http://www.dotnetfunda.com
Member since:Monday, September 10, 2012
Level:Starter
Status: [Member]
Biography:
>> Write Response - Respond to this post and get points
Related Posts

Entity Framework supported the development of applications using Schema first and Model First approach. Now, the new Entity Framework introduced the Code First approach.

This articles is 1st part of the 5 part series which gives overview of the Parallel Processing in Visual Studio 2010.

In this article, let us see how to bind a combobox with different columns from different datatables. eg. I have a datatable “Server” with columns server and database. Another datatable “server1” with columns servername and database name. Now I want to display all the values in the server and server name columns into a single combobox.

This article describes how to create XML file and also shows various ways of reading XML File in .NET using XmlTextReader, XmlDocumenet, XPathDocument, DataSet and XmlDataSource control.

This article talks about 6 ways of doing locking in .NET. It starts with concurrency problems and then discusses about 3 ways of doing optimistic locking. As optimistic locking does not solve the concurrency issues from roots, it introduces pessimistic locking. It then moves ahead to explain how isolation levels can help us implement pessimistic locking. Each isolation level is explained with sample demonstration to make concepts clearer.

More ...
About Us | Contact Us | The Team | Advertise | Software Development | Write for us | Testimonials | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you find plagiarised (copied) contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
Copyright © DotNetFunda.Com. All Rights Reserved. Copying or mimicking the site design and layout is prohibited. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks. | 5/19/2013 5:09:24 AM