Skip to content

System.Drawing.Common different versions between net8.0 and others lead to runtime error when calling from a class library #1906

@gitPhate

Description

@gitPhate

EPPlus usage

Personal use

Environment

Windows

Epplus version

7.6.1

Spreadsheet application

Excel

Description

EPPlus latest version (7.6.1) references EPPlus.System.Drawing version 7.6.1 which for some reasons have a lower version of System.Drawing.Common only for net8.0:

Image

This leads to a runtime error when creating a NET Standard class library using EPPlus and then reference that class library from a net8.0 starting project (e.g. console app). In fact when using any class from System.Drawing.Common from within the library you'll get:

System.IO.FileNotFoundException: 'Could not load file or assembly 'System.Drawing.Common, Version=9.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified.'

Here's a complete POC:
NET Standard project called MyClassLib:

public class Class1
    {
        public void MyMethod()
        {
            using (Graphics g = Graphics.FromHwnd(IntPtr.Zero)) //This is from System.Drawing.Common
            {
                //do stuff
            }
        }
    }

NET 8 console app:

using MyClassLib;

Class1 class1 = new();
class1.MyMethod();

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions