I am trying to compile my first GH plugin with VisualStudio for Mac by opening the Provide Sample Code. When I try to compile it, I get the following error message:
/Users/rudolfneumerkel/Projects/HelloGrasshopper/HelloGrasshopper/HelloGrasshopperInfo.cs(21,21): Error CS1069: The type name ‘Bitmap’ could not be found in the namespace ‘System.Drawing’. This type has been forwarded to assembly ‘System.Drawing.Common, Version=0.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51’ Consider adding a reference to that assembly. (CS1069) (HelloGrasshopper)
when going to the Microsoft documentation, I see the following:
Note
In .NET 6 and later versions, the System.Drawing.Common package, which includes this type, is only supported on Windows operating systems. Use of this type in cross-platform apps causes compile-time warnings and run-time exceptions. For more information, see System.Drawing.Common only supported on Windows.
Is this a temporary thing, are there good workarounds?
Maybe the standard sample code that comes with the RhinoCommon NuGet package should be updated?
I gues instead SkiaSharp has to be used?
Thanks for bringing this up. System.Drawing and Windows Forms support is provided when running Rhino as we have our own implementation of both based on Core Graphics and Cocoa on Mac.
It looks like this is something that we need to fix up in the Rhino 8 templates in order to properly compile in .NET 7. For now, you can simply remove net7.0 as a target framework in the .csproj, making it look like this:
<TargetFrameworks>net48</TargetFrameworks>
Alternatively, if you do want to compile for .NET 7 as well (even though we recommend only distributing the net48 build if you want to support Rhino 7 or Rhino on Windows), you can add the following to the .csproj:
One bit of bad news, is that Visual Studio for Mac was recently retired, which is probably a good thing as they kept on breaking things. As an example, the latest version of VS for Mac I am getting a crash trying to load grasshopper while debugging . I’m not sure if you’ve run into the same or not.
Fortunately, Microsoft isn’t dropping Mac support and is investing energy into Visual Studio Code instead, which might turn out for the better. It has great debugging and intellisense when developing for Rhino, but does require a little more setup to get things going.
We will soon be updating all our guides for Mac development to use Visual Studio Code so it will hopefully make it easier to get started with it.
Hi @curtisw, we are working on adding support for Rhino 8 on Mac to the ShapeDiver plugin, and ideally would like to switch to VS Code asap. Could you provide a timeline on when the guides for Mac development will be updated?