Unreferenced assembly for System.Drawing in C# scripting component


(qythium) #1

Seems to be a bug in Grasshopper for Mac, when I use the C# scripting component to access an existing attribute on the GH canvas which is referenced from System.Drawing, eg:

PointF pivot = this.Component.Pivot;

Results in this error:

Error (CS0012): The type ‘System.Drawing.PointF’ is defined in an assembly that is not referenced. Consider adding a reference to assembly ‘System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a’ (line 90)
Error (): /Applications/RhinoWIP.app/Contents/Resources/ManagedPlugIns/GrasshopperPlugin.rhp/Grasshopper.dll (Location of the symbol related to previous error)
Error (CS0029): Cannot implicitly convert type ‘System.Drawing.PointF [System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]’ to ‘System.Drawing.PointF [System.Drawing, Version=1.0.6604.16687, Culture=neutral, PublicKeyToken=null]’ (line 90)

The same code works on Windows and in GhPython ( pivot = ghenv.Component.Attributes.Pivot ).


Exporting bitmap from closed curves/hatches
(qythium) #2

More sanity checks (C# scripting component on Mac)
GH_ButtonObject and Pivot are used as examples, the same happens for other objects and their drawing attributes.

Get the script’s referenced assembly:

Print("{0}", typeof(PointF).AssemblyQualifiedName);

// Printed
// ========
System.Drawing.PointF, System.Drawing, Version=1.0.6604.16687, Culture=neutral, PublicKeyToken=null

With any object on canvas:

Print("{0}", this.Component.Attributes.Pivot.GetType().AssemblyQualifiedName);
Print("{0}", GrasshopperDocument.Objects[0].Attributes.Pivot.GetType().AssemblyQualifiedName);

// ERROR
// =========
Error (CS0012): The type `System.Drawing.PointF` is defined in an assembly that is not referenced. 
Consider adding a reference to assembly `System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a` (line 90)

Instantiate but don’t add to document:

Print("{0}", new Grasshopper.Kernel.Special.GH_ButtonObject().Attributes.Pivot);

// Same error as above
// ======================
Error (CS0012): The type `System.Drawing.PointF` is defined in an assembly that is not referenced. 
Consider adding a reference to assembly `System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a` (line 90)

But strangely this works:

Print("{0}", typeof(Grasshopper.Kernel.Special.GH_ButtonObjectAttributes).GetProperty("Pivot").PropertyType.AssemblyQualifiedName);

// Printed
// ========
System.Drawing.PointF, System.Drawing, Version=1.0.6604.16687, Culture=neutral, PublicKeyToken=null

So it seems like something is happening in the object’s constructor that causes it to reference the 4.0.0.0 assembly? Does anyone else running Grasshopper on a mac encounter the same problem?

(All tests run on Python and on Windows return the expected Version=1.0.6604.16687 of the assembly.)


(Dan Belcher) #3

Whoah. Sorry, this slipped off my radar. I’ll look into this ASAP.


(Dan Belcher) #5

I am able to duplicate this. Logged as RH-45410. Sorry this took so long to sanity-check. Thanks for reporting this!