From 33add6f1a74b2211f2d533c2c7bfa61ae3f0163a Mon Sep 17 00:00:00 2001 From: tom-englert Date: Tue, 18 Feb 2025 17:57:02 +0100 Subject: [PATCH 1/2] Fix #3402: System.NullReferenceException on right click on .NET 9 --- Directory.Packages.props | 10 +++++----- ILSpy/AssemblyTree/AssemblyTreeModel.cs | 1 + 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index a84164d03e..f9cbde7a7b 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -27,7 +27,7 @@ - + @@ -45,10 +45,10 @@ - - - - + + + + diff --git a/ILSpy/AssemblyTree/AssemblyTreeModel.cs b/ILSpy/AssemblyTree/AssemblyTreeModel.cs index 11df013904..b56b50f126 100644 --- a/ILSpy/AssemblyTree/AssemblyTreeModel.cs +++ b/ILSpy/AssemblyTree/AssemblyTreeModel.cs @@ -767,6 +767,7 @@ private void TreeView_SelectionChanged() } else { + ContextMenuProvider.ContextMenuClosed -= ContextMenuClosed; ContextMenuProvider.ContextMenuClosed += ContextMenuClosed; } } From 94990fbdc467ce143be442245526d206824a80c6 Mon Sep 17 00:00:00 2001 From: tom-englert Date: Wed, 19 Feb 2025 16:34:05 +0100 Subject: [PATCH 2/2] Add comments to clarify about used design pattern --- ILSpy/AssemblyTree/AssemblyTreeModel.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/ILSpy/AssemblyTree/AssemblyTreeModel.cs b/ILSpy/AssemblyTree/AssemblyTreeModel.cs index b56b50f126..dd5ba6fba1 100644 --- a/ILSpy/AssemblyTree/AssemblyTreeModel.cs +++ b/ILSpy/AssemblyTree/AssemblyTreeModel.cs @@ -767,6 +767,7 @@ private void TreeView_SelectionChanged() } else { + // ensure that we are only connected once to the event, else we might get multiple notifications ContextMenuProvider.ContextMenuClosed -= ContextMenuClosed; ContextMenuProvider.ContextMenuClosed += ContextMenuClosed; }