question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Which version of System.Drawing.Common should ScottPlot depend on?

See original GitHub issue

A new version of the System.Drawing.Common package is released with every major .NET version

Which version should ScottPlot depend on? How often (if ever) should it be changed?

Currently ScottPlot 4.0 depends on 4.7.0 and ScottPlot 4.1 depends on 5.0.0, but these weren’t chosen intentionally

Both could be upgraded to the latest (5.0.2) but I’m not sure if this would fix problems or cause more pain

Alternatively I could make it so each build target uses the version-matched System.Drawing.Common

Related: #993, #924, #655

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:13 (13 by maintainers)

github_iconTop GitHub Comments

4reactions
swhardencommented, May 2, 2021

Did you first downgrade Sys.Drawing.Common to 4.7.0? Close VS. Then modify the app config as i did. Still crashes? Edit: i did not delete the binding line, but modified it.

Actually it does work now. I closed VS, deleted the bin and obj folders, edited App.config to delete the bindingRedirect line, then opened the project in Visual Studio and it worked.

I think we’ve converged on a solution here! 🥳

1reaction
swhardencommented, May 2, 2021

Description of the Problem

Hey I think we may have figured this out!

  • System.Drawing.Common 4.x uses assembly version 4.0.0.1
  • System.Drawing.Common 5.x uses assembly version 4.0.0.2

When you install version 5 it adds this line to App.config

<bindingRedirect oldVersion="0.0.0.0-4.0.0.2" newVersion="4.0.0.2" />

…but if you downgrade versions to 4.x (the 4.0.0.1 assembly) you’ll be messed-up because you won’t have 4.0.0.2 around. Your program will compile, but it may crash in designer view, or when you run it you’ll get an error:

System.IO.FileLoadException: ‘Could not load file or assembly ‘System.Drawing.Common, Version=4.0.0.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51’ or one of its dependencies. The located assembly’s manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)’ Inner Exception FileLoadException: Could not load file or assembly ‘System.Drawing.Common, Version=4.0.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51’ or one of its dependencies. The located assembly’s manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

Solution

  • Downgrade to System.Drawing.Common 4.x
  • Close Visual Studio
  • Delete the bin and obj folders
  • Edit App.config to delete the bindingRedirect line
  • Open the project in Visual Studio and rebuild the solution

ScottPlot should target an older version of System.Drawing.Common

Maybe this means the best solution here is to keep ScottPlot depending on an older version of System.Drawing.Common (461?) and let people upgrade if/as their other projects need to.

  • People who are already using version 5 won’t be negatively affected and can keep using it
  • People who start new .NET Framework projects won’t have this problem anymore (this is the advantage)
  • People who upgrade then downgrade will always have this problem regardless of what we do
Read more comments on GitHub >

github_iconTop Results From Across the Web

ScottPlot dependencies - ScottPlot FAQ
ScottPlot 4 depends on the System.Drawing.Common package to render plots. This has special considerations for modern .NET projects depending on which ...
Read more >
System.Drawing.Common only supported on Windows - .NET
Drawing. Common depends on. That implementation makes libgdiplus a non-trivial component.
Read more >
ScottPlot Changelog
ScottPlot 3.0.3. NuGet packages published 2019-05-29. Update NuGet package to depend on System.Drawing.Common. Contributors.
Read more >
System.Drawing.Common 7.0.0
README; Frameworks; Dependencies; Used By; Versions; Release Notes. Provides access to GDI+ graphics functionality. Commonly Used Types: System.Drawing.
Read more >
How do I install System.Drawing.Common in a project that ...
Drawings. Common. Example project depends on library and has reference to System. Drawings.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found