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.

System.Drawing.Common and LogDisplay load errors

See original GitHub issue

Under .NET 6 add-ins, the LogDisplay may fail to load with an error complaining about a set_Font method not found. This relates to a newer version of the assembly System.Drawing.Common being present in the output directory. There is a deep .NET 6 mess related to this file, and why it might be present after referencing some packages. See for example https://github.com/dotnet/runtime/issues/64592

If using the System.Configuration.ConfigurationManager it might help to reference version 6.0.0 instead of 6.0.1.

Otherwise, the file can be explicitly deleted in the build:

<Target Name="RemoveSystemDrawingCommon" AfterTargets="ResolveAssemblyReferences">
  <ItemGroup>
    <ReferencePath Remove="@(ReferencePath)" Condition="%(ReferencePath.NuGetPackageId) == 'System.Drawing.Common'" />
  </ItemGroup>
</Target>

Is this safe? Presumably not always.

Issue Analytics

  • State:open
  • Created 7 months ago
  • Comments:16 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
govertcommented, Mar 23, 2023

Yay!

0reactions
pferniecommented, Mar 29, 2023

I ran into this as well; unfortunately, i was unable to remove the intermediate dependency that was introducing System.Drawing.Common (NetMQ, in my case). I found that while the Target in this (and the linked) issue didn’t prevent the dll being copied into my output dir, the following did:

  <Target Name="RemoveSystemDrawingCommon" AfterTargets="ResolveAssemblyReferences">
    <ItemGroup>
      <ReferenceCopyLocalPaths Remove="@(ReferenceCopyLocalPaths)" Condition="%(ReferenceCopyLocalPaths.NuGetPackageId) == 'System.Drawing.Common'" />
    </ItemGroup>
  </Target>

From my reading of the linked issue, this seems to be a valid fix, although this is as you say a bit of a .net mess.

Read more comments on GitHub >

github_iconTop Results From Across the Web

System.Drawing.Common assembly not loading
im using dotnet 6 and in dotnet 6 the Bitmap package was moved to a download only package, no problem here, I just...
Read more >
System.Drawing.Common only supported on Windows - .NET
Learn about the .NET 6 breaking change where the System.Drawing.Common package is no longer supported on non-Windows operating systems.
Read more >
Why am I getting this error about System.Drawing? : r/csharp
I am trying to do stuff with images in C# (basically saving into an image file) and every solution to that that I've...
Read more >
Package System.Drawing.Common 6.0.0 is not compatible ...
I've been trying to write a small application that works with some bitmap images. The way this works was changed by Microsoft not...
Read more >
Oracle Primavera Submittal Exchange Design Team User ...
How to Upload or Change Your Company's Logo on the Submittal Exchange ... Log Display Options . ... Common Categories: Drawings, Specifications, Addenda....
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