C# compiler crash when assigning value to object variable

I’m experiencing a hard rhino/Grassshopper crash when trying to run the following simplified code in the Gh C# editor;

  public class Cell
    public double test
      get{return test;}
      set{test = value;}

And in the body of the script

    Cell f = new Cell();
    f.test = 100;

This does not happed when using the short syntax for get and set.

I couldn’t find anything on the forum that was similar. I’m fairly new to C#. Minimal file attached - be sure to disable solver before opening as on my system it triggers a crash straight away. Apparently I’m working with .Net version 4.0.30319.42000 and Rhino 7SR16.

Systeminfo dump;

Rhino 7 SR16 2022-3-2 (Rhino 7, 7.16.22061.03001, Git hash:master @ cc6be15b6ce31f6e0bdd60bc4ab637f70ad1ecd3)
License type: Educational, build 2022-03-02
License details: Cloud Zoo

Windows 10.0.19042 SR0.0 or greater (Physical RAM: 32Gb)

Computer platform: LAPTOP  - Plugged in [100% battery remaining]

Non-hybrid graphics configuration.
  Primary display and OpenGL: NVIDIA GeForce GTX 1060 (NVidia) Memory: 6GB, Driver date: 12-6-2021 (M-D-Y). OpenGL Ver: 4.6.0 NVIDIA 472.84
    > Integrated accelerated graphics device with 4 adapter port(s)
        - Windows Main Display is laptop's integrated screen or built-in port

Secondary graphics devices.
  Intel(R) UHD Graphics 630 (Intel) Memory: 1GB, Driver date: 12-23-2020 (M-D-Y).
    > Integrated graphics device with 3 adapter port(s)
        - Secondary monitor is laptop's integrated screen or built-in port

OpenGL Settings
  Safe mode: Off
  Use accelerated hardware modes: On
  Redraw scene when viewports are exposed: On
  Graphics level being used: OpenGL 4.6 (primary GPU's maximum)
  Anti-alias mode: 8x
  Mip Map Filtering: Linear
  Anisotropic Filtering Mode: High
  Vendor Name: NVIDIA Corporation
  Render version: 4.6
  Shading Language: 4.60 NVIDIA
  Driver Date: 12-6-2021
  Driver Version:
  Maximum Texture size: 32768 x 32768
  Z-Buffer depth: 24 bits
  Maximum Viewport size: 32768 x 32768
  Total Video Memory: 6 GB

Rhino plugins that do not ship with Rhino
  C:\Users\PB\AppData\Roaming\McNeel\Rhinoceros\7.0\Plug-ins\Fologram for Rhino (468a328b-20d9-494b-b9e1-cbe9f827d3a2)\2020.3.3.0\7\Fologram.IO.Rhino3d.Win7.rhp	"Fologram for Rhino"	2020.3.3.0
  C:\Users\PB\AppData\Roaming\McNeel\Rhinoceros\packages\7.0\EleFront\4.2.2\ElefrontProperties.rhp	"ElefrontProperties"
  C:\Users\PB\AppData\Roaming\McNeel\Rhinoceros\packages\7.0\NVIDIADenoiser\0.4.0\NVIDIADenoiser.Windows.rhp	"NVIDIADenoiser.Windows"

Rhino plugins that ship with Rhino
  C:\Program Files\Rhino 7\Plug-ins\Commands.rhp	"Commands"	7.16.22061.3001
  C:\Program Files\Rhino 7\Plug-ins\rdk.rhp	"Renderer Development Kit"	
  C:\Program Files\Rhino 7\Plug-ins\RhinoRenderCycles.rhp	"Rhino Render"	7.16.22061.3001
  C:\Program Files\Rhino 7\Plug-ins\rdk_etoui.rhp	"RDK_EtoUI"	7.16.22061.3001
  C:\Program Files\Rhino 7\Plug-ins\rdk_ui.rhp	"Renderer Development Kit UI"	
  C:\Program Files\Rhino 7\Plug-ins\NamedSnapshots.rhp	"Snapshots"	
  C:\Program Files\Rhino 7\Plug-ins\IronPython\RhinoDLR_Python.rhp	"IronPython"	7.16.22061.3001
  C:\Program Files\Rhino 7\Plug-ins\RhinoCycles.rhp	"RhinoCycles"	7.16.22061.3001
  C:\Program Files\Rhino 7\Plug-ins\Grasshopper\GrasshopperPlugin.rhp	"Grasshopper"	7.16.22061.3001
  C:\Program Files\Rhino 7\Plug-ins\Toolbars\Toolbars.rhp	"Toolbars"	7.16.22061.3001
  C:\Program Files\Rhino 7\Plug-ins\3dxrhino.rhp	"3Dconnexion 3D Mouse"	
  C:\Program Files\Rhino 7\Plug-ins\Displacement.rhp	"Displacement"

Set_Example.gh (2.9 KB)

I just tested a string type rather than an int/double and the proplem is still there.

This appears related to the setter, not the getter. Is it to do with the ‘value’ keyword?

The syntax is wrong, and you will get a stack overflow due to the setter calling itself. You need a backing field variable that has a different name than ‘test’.


Thank you so much for pointing me in the right direction - now I understand the examples I had looked at previously.

1 Like