Exception Thrown in Try-Catch Block

Jeff Gaines 351 Reputation points
2023-03-09T10:28:50.6766667+00:00

I am in the process of moving from VS 2008 to VS 2022 (Community) which is quite a big jump.

I have the following code:

void tlvContactPanel_SelectedItemChanged(object sender, JTreeNode selectedNode)
		{
			try
			{
				int recNum = Convert.ToInt16(selectedNode.Tag);
				SetCurrentRecordNumber(recNum);
				if(tabControlMain.SelectedTab  == tabPageAddEditRecord)
					editPanel.CurrentRecordNumber = recNum;
			}
			catch { }
		}

VS 2022 is throwing an exception if "selectedNode" is null but that's what the Try/Catch block is for, why is it throwing an exception?

Developer technologies | Visual Studio | Other
0 comments No comments
{count} votes

Accepted answer
  1. Olaf Helper 47,441 Reputation points
    2023-03-09T10:50:52.9133333+00:00

    It's a setting in Visual Studio, see Manage exceptions with the debugger in Visual Studio:

    • The debugger is configured to break execution before any handler is invoked.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.