dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
14.98k stars 4.66k forks source link

System.Drawing.Color .NET Core 2.2 unable to reference NuGet package #1112

Closed techyian closed 4 years ago

techyian commented 4 years ago

Hi,

I have a netcoreapp 2.2 project which I'm using for xunit testing (trying to move from net452). Within the project I reference colors from System.Drawing.Color and have downloaded System.Drawing.Primitives version 4.3 from NuGet. The issue I'm having is that the package reference resolves the dll built into netcoreapp2.2 (System.Drawing.Primitives 4.2) and will not use the later 4.3 NuGet dll. I've had a look inside the netcoreapp dll using JustDecompile, and can see that the struct is simply a stub and all the struct members return null. I also can't find version 4.2 on NuGet - I assume that's because it's a stub built into netcoreapp2.2?

Is there any way that I can use the downloaded NuGet package for use in this project? Does a later version of .NET Core include full support for System.Drawing.Primitives?

Thank you!

techyian commented 4 years ago

Just to add to this. I'm trying to run my unit tests using the XUnit console runner and this is launched via Mono on a Raspberry Pi.

When the test containing the Color calls is ran, I receive the following error:

System.TypeLoadException : Could not resolve type with token 0100000f from typeref (expected class 'System.Drawing.Color' in assembly 'System.Drawing.Primitives, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a')
      Stack Trace:
          at (wrapper managed-to-native) System.Reflection.RuntimeMethodInfo.InternalInvoke(System.Reflection.RuntimeMethodInfo,object,object[],System.Exception&)
          at System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x0006a] in <7b90a8780ac4414295b539b19eea7eea>:0
danmoseley commented 4 years ago

I don't know about this issue but 2.2 goes out of support tomorrow https://dotnet.microsoft.com/platform/support/policy/dotnet-core

Could you try 3.1?

techyian commented 4 years ago

Sorry for the delay in replying. I think this was caused by not having <OutputType>Exe</OutputType> specified within the project file. I've been trying to move my Full Framework projects over to .NET Core/Standard and that got missed!