C# Component Error in Rhino 8

Hi, I’ve got the following error when I drop the new C# component in the GH canvas:

  1. Error building code | Method not found: ‘System.ReadOnlySpan1<!0> System.Collections.Immutable.ImmutableArray1.AsSpan()’.

Furthermore, when I start typing something in it, Rhino crashes.

Any help would be much appreciated.
Many thanks

Hi Giuseppe

Would you be able to share the code inside?

Daan

Hi Daan,

Many thanks for the reply. There is actually nothing inside the code, it’s just the component itself. But even if I add a piece of code, I still have the same error

Did you get that file from somewhere in the internet or just opening Grasshopper and placing a C# component from scratch gives that error?

Hi Giuseppe

I presume that the C# component is expecting some standard initialization parameters/methods.
Normally this is added already, like this:

This is what I see when adding a C# component and not changing anything. This does not give an error, only a warning stating that no actual code is added to the component.

Do you also see this inside your component?

Daan

Hi Mikity, just placing a C# component from scratch

Hi Daan, the issue that I’m facing is with the new C# component in Rhino 8. I think what you are showing there is the old C# component in Rhino 7. Also, if I start typing something inside the component, Rhino crashes

Oh, I see… I did not know there was a difference then.
I don’t have Rhino 8 on this computer, but I can check later if I encounter the same issues.

Hi, this is an unusual error. I think you should be consulted by McNeel. Very likely you need to uninstall Rhino and clean install.

HI Giuseppe -

Please run the Rhino SystemInfo command and copy-paste the result here.
-wim

Hi Wim, thanks for your reply. Please here below the result:

Rhino 8 SR4 2024-2-13 (Rhino 8, 8.4.24044.15001)
License type: Commercial, build 2024-02-13
License details: Stand-Alone

Windows 10 (10.0.19045 SR0.0) or greater (Physical RAM: 32GB)
.NET Framework 4.8.4515.0

Hybrid graphics configuration.
Primary display: Intel(R) UHD Graphics (Intel) Memory: 1GB, Driver date: 10-6-2023 (M-D-Y).
> Integrated graphics device with 4 adapter port(s)
- Secondary monitor is laptop’s integrated screen or built-in port
- Secondary monitor attached to adapter port #1
- Windows Main Display attached to adapter port #2
Primary OpenGL: NVIDIA RTX A3000 Laptop GPU (NVidia) Memory: 6GB, Driver date: 10-13-2023 (M-D-Y). OpenGL Ver: 4.6.0 NVIDIA 529.19
> Integrated accelerated graphics device with 4 adapter port(s)
- Video pass-through to primary display device

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: 4x
Mip Map Filtering: Linear
Anisotropic Filtering Mode: High

Vendor Name: NVIDIA Corporation
Render version: 4.6
Shading Language: 4.60 NVIDIA
Driver Date: 10-13-2023
Driver Version: 31.0.15.2919
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:\ProgramData\Beam\App\RHINOBEAM.dll “MKS BEAM” 1.10.1.1
C:\Program Files\Rhino 7\Plug-ins\Karamba\License\Karamba3D_LicensePlugin_Rhino7.rhp “Karamba3DLicense”
C:\ProgramData\McNeel\Rhinoceros\packages\8.0\LadybugTools\1.38.151\Ladybug.RH.Loader.rhp “Ladybug.RH.Loader” 1.38.151.0
C:\ProgramData\McNeel\Rhinoceros\packages\8.0\Pollination\1.42.5\Pollination.RH.Loader.rhp “Pollination.RH.Loader” 1.42.5.0

Rhino plugins that ship with Rhino
C:\Program Files\Rhino 8\Plug-ins\Commands.rhp “Commands” 8.4.24044.15001
C:\Program Files\Rhino 8\Plug-ins\rdk.rhp “Renderer Development Kit”
C:\Program Files\Rhino 8\Plug-ins\SectionTools.rhp “SectionTools”
C:\Program Files\Rhino 8\Plug-ins\RhinoRenderCycles.rhp “Rhino Render” 8.4.24044.15001
C:\Program Files\Rhino 8\Plug-ins\rdk_etoui.rhp “RDK_EtoUI” 8.4.24044.15001
C:\Program Files\Rhino 8\Plug-ins\NamedSnapshots.rhp “Snapshots”
C:\Program Files\Rhino 8\Plug-ins\MeshCommands.rhp “MeshCommands” 8.4.24044.15001
C:\Program Files\Rhino 8\Plug-ins\IronPython\RhinoDLR_Python.rhp “IronPython” 8.4.24044.15001
C:\Program Files\Rhino 8\Plug-ins\RhinoCycles.rhp “RhinoCycles” 8.4.24044.15001
C:\Program Files\Rhino 8\Plug-ins\RhinoCode\RhinoCodePlugin.rhp “RhinoCodePlugin” 8.4.24044.15001
C:\Program Files\Rhino 8\Plug-ins\Toolbars\Toolbars.rhp “Toolbars” 8.4.24044.15001
C:\Program Files\Rhino 8\Plug-ins\3dxrhino.rhp “3Dconnexion 3D Mouse”
C:\Program Files\Rhino 8\Plug-ins\Displacement.rhp “Displacement”

@wim Also, it’s worth mentioning that I have reinstalled Rhino 8 but the problem persists (including the fact that when I try to type something inside the C# component, Rhino crashes).

Hi Giuseppe -

Could you change your update frequency to service release candidates in Rhino and let that install a current 8.5 when that gets downloaded?

When Rhino crashes, does the crash reporter dialog pop up?
-wim

Hi,

Your version of Rhino is loading the .NET Framework and it seems that your C# script is referencing classes that are only available in later versions of dotnet.

Can you try this?
run the SetDotNetRuntime command and select Runtime=NETCore.
Restart Rhino.

@wim Hi Wim, thanks for your suggestions. I’ve changed the frequency and sent the crash report.

@Alain Hi Alain, actually I did change the runtime to .NET Framework since several GH plugins don’t work with .NET Core yet. Now I’ve changed it back to .NET Core as you suggested, and it seems that the C# component works fine. Would it be possible to make it work also with the .NET Framework?

The component should work with the .NET Framework. Maybe some some incompatible text is being used as the default template for some reason. Can you paste it’s contents here?
Thanks

Sure. This is what I see inside the C# component when I open it (without adding any personal input):

// Grasshopper Script Instance
using System;
using System.Collections;
using System.Collections.Generic;
using System.Drawing;

using Rhino;
using Rhino.Geometry;

using Grasshopper;
using Grasshopper.Kernel;
using Grasshopper.Kernel.Data;
using Grasshopper.Kernel.Types;

public class Script_Instance : GH_ScriptInstance
{
/*
Members:
RhinoDoc RhinoDocument
GH_Document GrasshopperDocument
IGH_Component Component
int Iteration

Methods (Virtual & overridable):
  Print(string text)
  Print(string format, params object[] args)
  Reflect(object obj)
  Reflect(object obj, string method_name)

*/

private void RunScript(object x, object y, ref object a)
{
// Write your logic here
a = null;
}
}

Thanks. I logged the issue here

@Alan Hi Alan, many thanks for that. Actually, I’ve just installed the new version 8 RS5 and it seems that the C# component works fine now, both with .NET Framework and .NET Core

PS: Fyi, I’ve got a 404 when I try to access your link above (possibly replate to restricted permission?).

Hi Giuseppe -

That should be open now.

So you are no longer experiencing crashes with this scripting component?
-wim