0

Today I'm working on an Excel add-in written in C# and Visual Studio keeps on breaking on a CryptographicException (see screenshot). It's not an exception handled by the code I'm developing, it's handled by the third party library I'm using. But VS still breaks on it. If I hit "Continue", the app will happily continue running even though the Exception isn't explicitly caught in the app anywhere. I don't have the source of the third party lib.

I enabled "Just My Code" and removed the check from "CryptographicException" in the Exception dialog, but it keeps breaking on the exception. And I read the related questions I could find. This question comes very close to what I'm asking but the OP still wants to see exceptions being thrown by third party libs whereas I only want to see the exceptions being unhandled in "my code".

So, is there a setting in Visual Studio that will allow me to do that?

Exception

Community
  • 1
  • 1
Vincent
  • 1,459
  • 15
  • 37
  • Possible duplicate of http://stackoverflow.com/questions/58380/avoiding-first-chance-exception-messages-when-the-exception-is-safely-handled – Amit Jan 14 '15 at 08:06
  • As visual studio says the exception is unhandled. It is not handled as you're claiming. – Sriram Sakthivel Jan 14 '15 at 08:07
  • @Amit the OP is talking about Exceptions showing up in his output console, from his own code. How is that a duplicate? – Vincent Jan 14 '15 at 08:12
  • @Sriram Sakthivel I assume it's handled or else my app would crash. I also tried putting a try...catch around the statement and I wasn't even able to catch the Crypto exception. So I think it's definitely getting handled. – Vincent Jan 14 '15 at 08:13
  • Don't assume. If visual studio says it is unhandled, definitely it is unhandled. Otherwise it will say Exception occurred not un handled. – Sriram Sakthivel Jan 14 '15 at 08:19
  • @Sriram Sakthivel Ok, I'd love to trust VS and I'm sure VS is right in saying it's unhandled. But why am I not able to catch it in my code then? And why does it still break on it when I check "just my code"? – Vincent Jan 14 '15 at 08:21

2 Answers2

2

Turns out all I had to do was disable this setting:

Visual Studio Debugging setting

For those interested, it's under Tools -> Options -> Debugging -> General -> top of the page.

Vincent
  • 1,459
  • 15
  • 37
0

Just my code will not prevent Visual Studio from breaking when an exception in 3rd party library is thrown. See Just my code

If an unhandled exception occurs in non-user code, the debugger breaks at the line in user code where the exception was generated. If first chance exceptions are enabled for the exception, the user-code line is highlighted in green.

The question is now, is it really unhandled (marked yellow) or is the line marked green -> handled.

Tobias Breuer
  • 825
  • 1
  • 11
  • 19
  • Green means the exception is handled. Not unhandeled. When having Just My Code enabled, your exception configuration dialog should show a checkbox to not break on handled exceptions any more. see: http://stackoverflow.com/questions/11183099/how-to-make-visual-studio-break-only-on-unhandled-exceptions – Tobias Breuer Jan 14 '15 at 08:29
  • As said in my question, I unchecked that, see this screenshot: http://i.stack.imgur.com/8dR90.png. But it still breaks on the exception. – Vincent Jan 14 '15 at 08:50