473,383 Members | 1,863 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Exception Handling - .Net Runtime Error Unhandled Exceptions

I have built an asychronous TCP Server that uses the thread pool. I have two
levels of exception handling in case the handling of the inner catch block
throws an exception. The outer catch block does nothing put print a string
literal to our logging mechanism. The general structure for this is:

AsyncReceiveCallback
{
try
{
OnReceiveDelegate();
}
catch (SocketException)
{
...
}
catch (ObjectDisposedException)
{
...
}
catch (Exception ex)
{
...
}
}
catch (Exception ex)
{
...
}
}

The OnReceiveDelegate is what handles the application business logic and
this business logic also has exception handling, but in some cases it may not
catch everything. My question here is shouldn't my exception handling in the
AsyncReceiveCallback method catch any unhandled exception returning from the
OnReceiveDelegate method?

Aug 31 '06 #1
3 3171
Note: I accidentally left out the top try:

AsyncReceiveCallback
{
try
{
try
{
OnReceiveDelegate();
}
catch (SocketException)
{
...
}
catch (ObjectDisposedException)
{
...
}
catch (Exception ex)
{
...
}
}
catch (Exception ex)
{
...
}
}
"Larry Herbinaux" wrote:
I have built an asychronous TCP Server that uses the thread pool. I have two
levels of exception handling in case the handling of the inner catch block
throws an exception. The outer catch block does nothing put print a string
literal to our logging mechanism. The general structure for this is:

AsyncReceiveCallback
{
try
{
OnReceiveDelegate();
}
catch (SocketException)
{
...
}
catch (ObjectDisposedException)
{
...
}
catch (Exception ex)
{
...
}
}
catch (Exception ex)
{
...
}
}

The OnReceiveDelegate is what handles the application business logic and
this business logic also has exception handling, but in some cases it may not
catch everything. My question here is shouldn't my exception handling in the
AsyncReceiveCallback method catch any unhandled exception returning from the
OnReceiveDelegate method?
Aug 31 '06 #2
Larry,

Yes. It should catch any exception thrown by OnReceiveDelegate. In
fact, it should catch any exceptions thrown by the catch blocks of the
inner try-catch block as well. The only way AsyncReceiveCallback can
throw an exception is if the outer catch block generates it. Are you
observing different behavior?

Brian

Larry Herbinaux wrote:
Note: I accidentally left out the top try:

AsyncReceiveCallback
{
try
{
try
{
OnReceiveDelegate();
}
catch (SocketException)
{
...
}
catch (ObjectDisposedException)
{
...
}
catch (Exception ex)
{
...
}
}
catch (Exception ex)
{
...
}
}
"Larry Herbinaux" wrote:
I have built an asychronous TCP Server that uses the thread pool. I have two
levels of exception handling in case the handling of the inner catch block
throws an exception. The outer catch block does nothing put print a string
literal to our logging mechanism. The general structure for this is:

AsyncReceiveCallback
{
try
{
OnReceiveDelegate();
}
catch (SocketException)
{
...
}
catch (ObjectDisposedException)
{
...
}
catch (Exception ex)
{
...
}
}
catch (Exception ex)
{
...
}
}

The OnReceiveDelegate is what handles the application business logic and
this business logic also has exception handling, but in some cases it may not
catch everything. My question here is shouldn't my exception handling in the
AsyncReceiveCallback method catch any unhandled exception returning from the
OnReceiveDelegate method?
Sep 1 '06 #3
Brian,

Yes we are having some exceptions that cause a .Net Runtime error. We have
at least one general business logic exception that we are looking into, but
we also see it in our production environment when we switch from one DB
Cluster Node to another (not all the time...but this could be to timing
issues...e.g. in the middle of a SQL Request or not when switch occurs).

"Brian Gideon" wrote:
Larry,

Yes. It should catch any exception thrown by OnReceiveDelegate. In
fact, it should catch any exceptions thrown by the catch blocks of the
inner try-catch block as well. The only way AsyncReceiveCallback can
throw an exception is if the outer catch block generates it. Are you
observing different behavior?

Brian

Larry Herbinaux wrote:
Note: I accidentally left out the top try:

AsyncReceiveCallback
{
try
{
try
{
OnReceiveDelegate();
}
catch (SocketException)
{
...
}
catch (ObjectDisposedException)
{
...
}
catch (Exception ex)
{
...
}
}
catch (Exception ex)
{
...
}
}
"Larry Herbinaux" wrote:
I have built an asychronous TCP Server that uses the thread pool. I have two
levels of exception handling in case the handling of the inner catch block
throws an exception. The outer catch block does nothing put print a string
literal to our logging mechanism. The general structure for this is:
>
AsyncReceiveCallback
{
try
{
OnReceiveDelegate();
}
catch (SocketException)
{
...
}
catch (ObjectDisposedException)
{
...
}
catch (Exception ex)
{
...
}
}
catch (Exception ex)
{
...
}
}
>
The OnReceiveDelegate is what handles the application business logic and
this business logic also has exception handling, but in some cases it may not
catch everything. My question here is shouldn't my exception handling in the
AsyncReceiveCallback method catch any unhandled exception returning from the
OnReceiveDelegate method?
>

Sep 4 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

44
by: craig | last post by:
I am wondering if there are some best practices for determining a strategy for using try/catch blocks within an application. My current thoughts are: 1. The code the initiates any high-level...
6
by: Nick Reeves | last post by:
While developing the below code I noticed that exceptions were not working as expected. An exception is thrown inside an XML import DLL and not being caught inside the Main() code fragment,...
4
by: Frank | last post by:
Hi, I made a handler for unhandled errors. But before that is executed, VB.NET gives me the standard error window. In VB6 there was a setting (errortrapping) about handling errors in the design...
2
by: Nak | last post by:
Hi there, I'm just curious as to something. I have just added an exception handler at the entry point to my application, within the IDE any unhandled exceptions fallback to this and enable me...
5
by: Samuel R. Neff | last post by:
When you have an unhandled exception in vb.net how do you view the exception information in the debugger? In C# the debugger creates a local variable that points to the exception and you can...
11
by: chopsnsauce | last post by:
Here's the example: Dim frm As New FORM1 Try frm.show Catch ex As Exception msgbox ex.message
16
by: Chuck Cobb | last post by:
I'm implementing a centralized exception handling routine using the Enterprise Library Exception Management Application Block. I trap all unhandled exceptions to one place using the following...
6
by: Phillip Taylor | last post by:
I don't like the way every time I write a bad sql query the debugger takes me to the database access code. It's extremely stable and reliable and the exceptions being thrown are because of SQL...
6
by: Steve | last post by:
Hi All I have a windows forms Application (SAM) in vb.net 2008 using .net framework V2 One and only one customer out of 30 customers is getting errors daily where they have to close and...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.