简体   繁体   中英

.NET Standard 2.0 library referenced by .NET 4.6.1 project - Wrong version of Drawing library referenced

I am trying to get a .NET standard 2.0 library (that uses System.Drawing) to be referenced by a .NET 4.6.1 project (that implements a function that passes the ImageFormat enum).

I get the following error in the implementing project.

The type 'ImageFormat' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Drawing.Common, Version=4.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'.

The .NET standard 2.0 library includes the nuget package System.Drawing.Common 4.5.0 (which includes ImageFormat).

The .NET 4.6.1 project references System.Drawing 4.0.0 (which also includes ImageFormat).

4.5.0 vs 4.0.0

So the message makes sense... I am not referencing the correct version of System.Drawing in the .NET project!

But I can't work out what I need to do to resolve it.

Can anyone please help?

I had a similar problem. I couldnt use anything from .netCore and i had a similar error message and what i did was to right click to the solution and to open the nuget manager and to install the .netCore manualy and it worked. Try it and see if it works. Greetings!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM