Debugger in .NET Core 3.1 doesn't show the row of problem when error occurs RRS feed

  • Question

  • Hello!

    I have a problem with .NET Core 3.1 Windows Form App application when I debug.

    Normally in the .NET Framework application, when an error occurs, the debugger goes to the EXACT line where the problem occurs but the .NET Core 3.1 shows a "ThrowHelper.cs" file with the problem which means that I don't know where the problem occurs.

    System.ArgumentOutOfRangeException: 'Index was out of range. Must be non-negative and less than the size of the collection. 

    I am not sure how to enable the debugger to work correctly?

            private void button1_Click(object sender, EventArgs e)
                List<String> list1 = new List<String>();

    • Edited by Silvers11 Saturday, April 25, 2020 10:48 PM
    Saturday, April 25, 2020 10:47 PM

All replies

  • Well the list1 was just created and it's empty.

    Then you try to do a list1[0] using an index trying to get the first item in list1. List1 is empty, and you're going to get the error message you're getting.

    If (list1.count > 0)




    As for the debugger and stopping on an exception you may have to enable it.


    • Edited by DA924x Saturday, April 25, 2020 11:16 PM
    Saturday, April 25, 2020 11:15 PM
  • Show a screen shot of what you see.

    Sam Hobbs

    Sunday, April 26, 2020 6:22 PM
  • Looks for me, like you end up in system-code.
    Would verify that in
    'Enable Just My Code' 
    is enabled.

    If no help, in 'Call Stack window'
    Debug->Windows->Call Stack
    it might be possible to switch to relevant stack frame, by double-clicking respective entry.

    With kind regards
    Sunday, April 26, 2020 11:21 PM