Home > Enterprise >  Track down "Exception Thrown: " message in .Net Core
Track down "Exception Thrown: " message in .Net Core

Time:11-06

I am building a NuGet, and in my Visual Studio Output window I am getting this:

Exception thrown: 'System.InvalidCastException' in MyLibraryNameHere.dll

Obviously I have an invalid cast happening, but I am not able to find out where it is happening.

It does not cause any kind of break or stack trace or anything else that I can use to track it down.

I assume it is happening on a different thread than the main one, and that is why it is not causing a break to happen.

Is there some way to get more information? Or have Visual Studio break the debugging when an error happens on a background thread?

CodePudding user response:

In the Debug menu select Exception settings and select all types of CLR exceptions (or just InvalidCastException in your case). Then the debugger will break on those exceptions even if you have an exception handler (try/catch block) in your code.

  • Related