1

I have unusual (for me) problem with thrown exception. After exception is thrown application loops on it and doesn't exit.

if(!foundRemoteID) { throw new ArgumentOutOfRangeException( "value", "Remote ID was not found." ); } 

I have inserted brakepoint on "if(!foundRemoteID)" line but the program doesn't hit it at all after firs thrown exception. It just loops over and over on "throw new (..).

-I do not have try{} catch{} blocks at all at any level. -There is no loop that contains this code

I have even tried putting it into:

try { (..) } finally { Enviroment.Exit(1); } 

but finally{} block is never hit.

Other throw new (..) in this class is acting same way.

Am I missing something trivial?

UPDATE: Problem is not related to my project. I have just created a simple console application that has only

throw new FileNotFoundException(); 

In Main() method and problem persists.

I have already tried resetting VS2010 settings to default and it didn't help.

4
  • How are you determining that it loops? Are you running this from within the Visual Studio debugger? Commented Oct 14, 2013 at 19:23
  • It might be that you have some pending finalizers that must run afterward, causing this to happen!! Commented Oct 14, 2013 at 19:27
  • Toggle a breakpoint in the throw line and check call stack for any recursive call in your code. If no loop is wrapping your code, then must be a non-controlled recursive call. Commented Oct 14, 2013 at 19:29
  • Can you post some more code (the code before the if statement)? so it will be possible to tell you the correct problem that causing it... Commented Oct 14, 2013 at 19:30

1 Answer 1

4

Most likely this is not the actual behavior of your application - rather, Visual Studio is set to always break when there is an unhandled ArgumentOutOfRangeException.

You can verify this by pressing "Start without debugging".

If you want to change the settings, browse to the menu to Debug -> Exceptions and you should see the following. Then uncheck "User-unhandled."

Personally, I recommend leaving the setting the way it is in most cases. It really helps when hunting down unhandled exceptions.

Visual Studio Debug Exceptions

Sign up to request clarification or add additional context in comments.

8 Comments

Setting are in default. Application run without debugging (in Service mode) also returns exception and continues to work.
Ok, so this explains why your debugger gets stuck on that line, but you still have the issue of your application still running after the exception occurs. It's possible that somewhere in your code, the AppDomain.CurrentDomain.UnhandledException event handler was assigned to a method which is eating your exception.
If have looked all over the project (also in settings) but didn't found anything like that. Normal exceptions (not thrown by me) are working correctly by shutting down the application.
Try the directions I suggested in the answer, and then use the debugger to step past the line that throws the exception to see where the code is going.
I was already using "Step over" but it went straight to exception again. I have created new console application and inserted just "throw new (..)" and same thing happened. It must be something in my VS2010 configuration. If I find something I'll surely post it down here. However I wouldn't like to resort to "Reset to default". EDIT: I have just use Reset to Default option and problem persists. That is going to be a long night.....
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.