Skip to content

Add .NET 8/9/10 target frameworks to fix BinaryFormatter crash in GViewer#396

Open
Copilot wants to merge 5 commits into
masterfrom
copilot/fix-crash-in-dotnet-9
Open

Add .NET 8/9/10 target frameworks to fix BinaryFormatter crash in GViewer#396
Copilot wants to merge 5 commits into
masterfrom
copilot/fix-crash-in-dotnet-9

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jun 3, 2026

GViewer() crashes on .NET 9+ with PlatformNotSupportedException because GViewer.resx embeds an ImageListStreamer as application/x-microsoft.net.object.binary.base64 — a format requiring BinaryFormatter, which was completely removed in .NET 9.

Windows Forms in .NET 9+ reimplemented ImageListStreamer deserialization without BinaryFormatter. The fix is to ship dedicated TFM binaries so .NET 9/10 consumers get the runtime that handles this natively.

Core library (GraphViewerGDI)

  • Extend TargetFrameworks: net472;net6.0-windowsnet472;net6.0-windows;net8.0-windows;net9.0-windows;net10.0-windows
  • Add <GenerateResourceUsePreserializedResources>true</GenerateResourceUsePreserializedResources> — required by the .NET 10 SDK for projects with binary .resx resources targeting net472
  • Update GraphViewerGDI.nuspec with dependencies and <files> entries for the three new TFMs

Downstream projects

Add net8.0-windows, net9.0-windows, net10.0-windows TFMs to:

  • Tools: FormForGViewer, DebugCurveViewer, agl, WpfGraphControl, GraphmapsWpfControl
  • Tests: TestFormForGViewer, TestForGDI, Test01, VoronoiDiagramTest, TestGraphmaps
  • Samples: all 23 sample projects targeting net472;net6.0-windows or net6.0-windows
  • WriteToSvgSample / SvgLayerSample (non-Windows): extend with net8.0, net9.0, net10.0

Copilot AI linked an issue Jun 3, 2026 that may be closed by this pull request
…works

- GraphViewerGDI: add net8.0-windows, net9.0-windows, net10.0-windows TFMs
- GraphViewerGDI: add GenerateResourceUsePreserializedResources=true for net472 fix
- GraphViewerGDI.nuspec: add NuGet entries for new TFMs
- All tool, test, and sample projects: add net8/9/10-windows TFMs
Copilot AI changed the title [WIP] Fix crash in .NET 9 due to missing BinaryFormatter Add .NET 8/9/10 target frameworks to fix BinaryFormatter crash in GViewer Jun 3, 2026
Copilot AI requested a review from levnach June 3, 2026 23:07
Restore lines clobbered while adding net8/9/10 TFMs:
- RootNamespace in TestForGDI, Test01, DebugCurveViewer, FormForGViewer
- UseWPF in WpfGraphControl, GraphmapsWpfControl
- UseWindowsForms/WarningLevel in agl

Fixes invalid XML (MSB4025) and broken WPF builds so all projects
build on net9/net10 while keeping the BinaryFormatter crash fix.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Comment on lines +49 to +57
<group targetFramework="net8.0-windows7.0">
<frameworkReference name="Microsoft.WindowsDesktop.App.WinForms" />
</group>
<group targetFramework="net9.0-windows7.0">
<frameworkReference name="Microsoft.WindowsDesktop.App.WinForms" />
</group>
<group targetFramework="net10.0-windows7.0">
<frameworkReference name="Microsoft.WindowsDesktop.App.WinForms" />
</group>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot, most likely this not needed. Adding this for modern Target Frameworks (like net9, net10) will (most likely) cause #390.

@snechaev
Copy link
Copy Markdown
Contributor

snechaev commented Jun 4, 2026

@copilot, consider to review and update WpfGraphControl.nuspec to include the build artifacts for the newly added TFMs in the WPF-specific package. Beware of #390.

Copilot CLI and others added 2 commits June 4, 2026 09:44
GraphViewerGDI.nuspec: remove frameworkReference entries for net8/9/10
(only net6 kept); adding Microsoft.WindowsDesktop.App.WinForms for modern
TFMs triggers issue #390 (NETSDK1073).

WpfGraphControl.nuspec: add dependency groups and lib file entries for
net8/9/10-windows so the WPF package ships the new TFM build artifacts,
without adding frameworkReference entries (beware of issue #390).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@levnach levnach marked this pull request as ready for review June 4, 2026 16:53
@levnach levnach requested review from Copilot and levnach June 4, 2026 16:55
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR expands the target frameworks across MSAGL’s WinForms/WPF viewer components, tools, tests, and samples to produce dedicated net8.0*, net9.0*, and net10.0* binaries so that .NET 9+ consumers avoid the BinaryFormatter-based ImageListStreamer .resx deserialization crash, and updates NuGet packaging accordingly.

Changes:

  • Multi-targets Windows desktop projects with net8.0-windows, net9.0-windows, net10.0-windows (in addition to existing net472/net6.0-windows).
  • Updates GraphViewerGDI build settings for binary .resx resources via GenerateResourceUsePreserializedResources=true.
  • Extends .nuspec dependency groups and lib/ assets to ship assemblies for the new TFMs.

Reviewed changes

Copilot reviewed 39 out of 39 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
GraphLayout/WriteToSvgSample/WriteToSvgSample.csproj Adds net8.0;net9.0;net10.0 multi-targeting for the non-Windows SVG sample.
GraphLayout/tools/WpfGraphControl/WpfGraphControl.nuspec Adds dependency groups and lib/ entries for net8/9/10 assets.
GraphLayout/tools/WpfGraphControl/WpfGraphControl.csproj Adds net8/9/10-windows TFMs to build WPF control binaries for newer runtimes.
GraphLayout/tools/GraphViewerGDI/GraphViewerGDI.nuspec Adds dependency groups and lib/ entries for net8/9/10 assets.
GraphLayout/tools/GraphViewerGDI/GraphViewerGDI.csproj Adds net8/9/10-windows TFMs and enables preserialized resources for binary .resx.
GraphLayout/tools/GraphmapsWpfControl/GraphmapsWpfControl.csproj Adds net8/9/10-windows TFMs for downstream WPF control.
GraphLayout/tools/FormForGViewer/FormForGViewer.csproj Adds net8/9/10-windows TFMs for downstream tool/library.
GraphLayout/tools/DebugCurveViewer/DebugCurveViewer.csproj Adds net8/9/10-windows TFMs for downstream tool.
GraphLayout/tools/agl/agl.csproj Adds net8/9/10-windows TFMs for downstream tool.
GraphLayout/TinyClickDemo/TinyClickDemo.csproj Adds net8/9/10-windows TFMs for a demo app.
GraphLayout/Test/VoronoiDiagramTest/VoronoiDiagramTest.csproj Adds net8/9/10-windows TFMs for test app.
GraphLayout/Test/TestGraphmaps/TestGraphmaps.csproj Extends existing test multi-targeting to include net9/10-windows.
GraphLayout/Test/TestFormForGViewer/TestFormForGViewer.csproj Adds net8/9/10-windows TFMs for test project.
GraphLayout/Test/TestForGDI/TestForGDI.csproj Adds net8/9/10-windows TFMs for test app.
GraphLayout/Test/Test01/Test01.csproj Adds net8/9/10-windows TFMs for test app.
GraphLayout/Samples/WpfApplicationSample/WpfApplicationSample.csproj Adds net8/9/10-windows TFMs for sample app.
GraphLayout/Samples/WpfApplicationSample_OnnxViewer/WpfApplicationSample_OnnxViewer.csproj Converts single target to multi-target including net8/9/10-windows.
GraphLayout/Samples/WindowsApplicationSample/WindowsApplicationSample.csproj Adds net8/9/10-windows TFMs for sample app.
GraphLayout/Samples/UsingMDSLayoutSample/UsingMDSLayoutSample.csproj Adds net8/9/10-windows TFMs for sample app.
GraphLayout/Samples/SvgLayerSample/SvgLayerSample.csproj Adds net8.0;net9.0;net10.0 multi-targeting for the non-Windows SVG sample.
GraphLayout/Samples/SimplestWinFormsSample/SimplestWinFormsSample.csproj Adds net8/9/10-windows TFMs for WinForms sample.
GraphLayout/Samples/SameLayerSample/SameLayerSample.csproj Adds net8/9/10-windows TFMs for sample app.
GraphLayout/Samples/PopulateGViewerWithPrecalculatedDrawingGraph/PopulateGViewerWithPrecalculatedDrawingGraph.csproj Adds net8/9/10-windows TFMs for WinForms sample.
GraphLayout/Samples/PhyloTreeSampleOverGDI/PhyloTreeSampleOverGDI.csproj Adds net8/9/10-windows TFMs for sample app.
GraphLayout/Samples/PhyloTreeFromGeometrySample/PhyloTreeFromGeometrySample.csproj Adds net8/9/10-windows TFMs for sample app.
GraphLayout/Samples/NodesWithImages/NodesWithImages.csproj Adds net8/9/10-windows TFMs for WinForms sample.
GraphLayout/Samples/MinWpfApp/MinWpfApp.csproj Adds net8/9/10-windows TFMs for WPF sample.
GraphLayout/Samples/LocationLabeling/LocationLabeler.csproj Adds net8/9/10-windows TFMs for sample app.
GraphLayout/Samples/LoadingDgmlGraph/LoadingDgmlGraph.csproj Adds net8/9/10-windows TFMs for WinForms sample.
GraphLayout/Samples/LayoutOfADisconnectedGraphWithSugiyama/LayoutOfADisconnectedGraphWithSugiyama.csproj Adds net8/9/10-windows TFMs for WinForms sample.
GraphLayout/Samples/LayerConstraintsFromGeometrySample/LayerConstraintsFromGeometrySample.csproj Adds net8/9/10-windows TFMs for WinForms sample.
GraphLayout/Samples/GeometryRoutinesSample/GeometryRoutinesSample.csproj Adds net8/9/10-windows TFMs for sample app.
GraphLayout/Samples/FindEmptySpotSample/FindEmptySpotSample.csproj Adds net8/9/10-windows TFMs for sample app.
GraphLayout/Samples/FastIncrementalLayoutWithGdi/FastIncrementalLayoutWithGdi.csproj Adds net8/9/10-windows TFMs for sample app.
GraphLayout/Samples/Editing/Editing.csproj Adds net8/9/10-windows TFMs for WinForms sample.
GraphLayout/Samples/EdgeRoutingSample/EdgeRoutingSample.csproj Adds net8/9/10-windows TFMs for sample app.
GraphLayout/Samples/EdgeDirectionTest/EdgeDirectionTest.csproj Adds net8/9/10-windows TFMs for sample app.
GraphLayout/Samples/DrawingFromGeometryGraphSample/DrawingFromGeometryGraphSample.csproj Adds net8/9/10-windows TFMs for sample app.
GraphLayout/Samples/AspectRatioSample/SettingGraphBoundsSample.csproj Adds net8/9/10-windows TFMs for sample app.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +28 to +36
<group targetFramework="net8.0-windows7.0">
<dependency id="Msagl.Drawing" version="BuildVersion" />
</group>
<group targetFramework="net9.0-windows7.0">
<dependency id="Msagl.Drawing" version="BuildVersion" />
</group>
<group targetFramework="net10.0-windows7.0">
<dependency id="Msagl.Drawing" version="BuildVersion" />
</group>
Comment on lines +35 to +43
<group targetFramework="net8.0-windows7.0">
<dependency id="Msagl.Drawing" version="BuildVersion" />
</group>
<group targetFramework="net9.0-windows7.0">
<dependency id="Msagl.Drawing" version="BuildVersion" />
</group>
<group targetFramework="net10.0-windows7.0">
<dependency id="Msagl.Drawing" version="BuildVersion" />
</group>
@levnach levnach requested a review from NikolajBjorner June 4, 2026 17:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Crash in .Net 9 due to missing BinaryFormatter

5 participants