Error CS0246: The type or namespace name 'Color' could not be found

I am migrating an application from .NET Framework 4.6.1 to .NET Core 3.1. I added the following nuget reference to the new project: FastReport.OpenSource - 2019.2.0 (to match the version of dlls used in the old project)


Everything works fine, the code compiles easily, until I ran the code and hit the report.Prepare(true); instruction. I get the following error:

(102,18): Error CS0246: The type or namespace name 'Color' could not be found (are you missing a using directive or an assembly reference?)

(108,18): Error CS0246: The type or namespace name 'Color' could not be found (are you missing a using directive or an assembly reference?)

(114,18): Error CS0246: The type or namespace name 'Color' could not be found (are you missing a using directive or an assembly reference?)

(120,18): Error CS0246: The type or namespace name 'Color' could not be found (are you missing a using directive or an assembly reference?)

(126,18): Error CS0246: The type or namespace name 'Color' could not be found (are you missing a using directive or an assembly reference?)

(132,18): Error CS0246: The type or namespace name 'Color' could not be found (are you missing a using directive or an assembly reference?)

(138,18): Error CS0246: The type or namespace name 'Color' could not be found (are you missing a using directive or an assembly reference?)

(144,18): Error CS0246: The type or namespace name 'Color' could not be found (are you missing a using directive or an assembly reference?)

(150,18): Error CS0246: The type or namespace name 'Color' could not be found (are you missing a using directive or an assembly reference?)

(104,15): Error CS0103: The name 'Color' does not exist in the current context

(110,15): Error CS0103: The name 'Color' does not exist in the current context

(116,15): Error CS0103: The name 'Color' does not exist in the current context

(122,15): Error CS0103: The name 'Color' does not exist in the current context

(128,15): Error CS0103: The name 'Color' does not exist in the current context

(134,15): Error CS0103: The name 'Color' does not exist in the current context

(140,15): Error CS0103: The name 'Color' does not exist in the current context

(146,15): Error CS0103: The name 'Color' does not exist in the current context

(152,15): Error CS0103: The name 'Color' does not exist in the current context

(70,29): Error CS0012: The type 'Color' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Drawing.Primitives, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.

(76,26): Error CS0012: The type 'Color' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Drawing.Primitives, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.

(77,26): Error CS0012: The type 'Color' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Drawing.Primitives, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.

(80,26): Error CS0012: The type 'Color' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Drawing.Primitives, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.

(81,26): Error CS0012: The type 'Color' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Drawing.Primitives, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.

(84,26): Error CS0012: The type 'Color' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Drawing.Primitives, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.

(85,26): Error CS0012: The type 'Color' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Drawing.Primitives, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.

(85,38): Error CS0103: The name 'Color' does not exist in the current context


Here is the code:

using var report = new Report();
using var reportTemplate = new MemoryStream(Resources.ReportFile); // Our CustomReport.frx

report.Load(reportTemplate);

// Setting some parameters
report.SetParameterValue([..]);

// Registering some data
report.RegisterData([..])

report.Prepare(true);


The frx file contains, in its script part, 9 custom defined colors, like this:

 public static Color ErrorAlarm{
     get{
       return Color.FromArgb(255, 48, 48);
     }
   }

So I suspect the issue is probably linked to this. But I don't understand why FastReport is complaining about System.Drawing.Primitives, since it exists in .NET Core 3.1...


I also tried to upgrade the FastReport.OpenSource to newer versions (including the last one), but I always get either the same error or a NullReferenceException, when the program hit report.Prepare(true).

Comments

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.