Debugger enters infinite loop when in a multiple Catch process

I have the following code in my server:

try
{
if ( queueFactory == null )
queueFactory = new ChannelFactory<ICompassQueueService>( "QueueHost" );
if ( queueAddress == null )
queueChannel = queueFactory.CreateChannel( );
else
queueChannel = queueFactory.CreateChannel( queueAddress );

( ( IClientChannel )queueChannel ).Open( );
}
catch ( EndpointNotFoundException epnf )
{
( ( IClientChannel )queueChannel ).Abort( );
throw new CommunicationException( "The server is not available at this time. Try again later.", epnf );
}
catch ( Exception ex )
{
( ( IClientChannel )queueChannel ).Abort( );
throw;
}

When I throw the CommunicationException, the debugger highlights the catch (Exception ex) block with a window that says CommunicationException not handled. When I hit PF11 (to continue execution) it just goes into an infinite loop highlighting the throw new CommunicationException then the catch (Exception) then the throw than the catch than the throw than the catch than ....

Visual Studio 2003 NEVER EVER did this.

[1177 byte] By [MichaelEber] at [2008-1-7]
# 1

Hi MichaelEber,

What verison of Visual Studio are you using?

Liz

Liz-MSFT at 2007-10-2 > top of Msdn Tech,Visual Studio,Visual Studio Debugger...
# 2

MichaelEber,

The CommunicationException you are throwing is going unhandled (i.e. your application has crashed.). The managed debugger does not terminate the process after you step over an unhandled exception. It does this to continue showing the developer exactly what caused the application to crash.

The catch block is being highlighted because you have first-chance notifications enabled. (The debugger will often show the next statement after a first-chance notification ... i.e. the catch block in this scenario). That means the debugger is notifying you of when the exception is thrown before the unwind occurs. When you step over the first-chance notification, the unwind happens. In this case, no-one catches the exception so, it goes unhandled and you are shown the unhandled exception dialog.

Hope that makes sense

Jackson

JacksonDavis-MSFT at 2007-10-2 > top of Msdn Tech,Visual Studio,Visual Studio Debugger...

Visual Studio

Site Classified