How to make a NuGet thrown exception appear at the method call?


When you’re coding and you encounter an error, such as the following, you receive an error at the line of code where you attempted the error.


For reference, in Visual Studio Community this looks like this:
Normal unhandled exception

However, I’m designing a NuGet package (like a DLL) and sometimes I want to throw an exception, like an ArgumentException, if the user tries to pass invalid strings to a function. However, when I code this into the NuGet and then proceed to use an invalid string, the exception takes me to the line of code in my NuGet where I threw the exception, not the line of code where I attempted the error.

For example: NuGet thrown exception

I’m curious why Visual Studio takes me to the function in the NuGet code instead of where I made the invalid call. Any idea what I’m doing wrong here?

Source: Visual Studio Questions