In testing out some of my C# scripts in the Rhino 8 (8 SR15) ScriptEditor I have come across the following.
The following very simple example code runs fine when the green arrow or F5 is pressed in the script editor.
// #! csharp
using System;
using Rhino;
public class Test
{
public static void TestMethod()
{
RhinoApp.WriteLine("This is a test");
}
}
Test.TestMethod();
However, when a breakpoint is added (to the line RhinoApp.WriteLine("This is a test");) for example, the following error is returned.
Compile Error
Keyword ‘this’ is not valid in a static property, static method, or static field initializer (Error CS0026)
As you can imagine, this makes it a lot more challenging to debug code.
I welcome suggestions as to how I can debug Rhino C# code with breakpoints in the script editor. I know I can also debug with breakpoints step by step in Visual Studio, but then I need to reload Rhino with every time I run the plugin. Script editor provides a nice intermediate step to get smaller blocks of code working before putting them into a full blown plugin.
Sometimes that dialog needs restarting Rhino and/or rebooting the system.
You can just click the “Check Now…” link and manually download the current 8.16 release candidate.
-wim
@eirannejad I believe the issue has resurfaced. I am using the latest SR to date (SR24) and I am getting a swathe of errors in debugging when adding a breakpoint to a script that works in Run mode.
Sorry in advance for the lengthy script. I have tried to reduce it to its bare minimum to reproduce the errors when adding a breakpoint; the script runs when normally executed, it’s just that I cannot add a breakpoint to check for error-catching in case the wrong object is selected. The log shows some weird errors in a non-existing position [22:664] (line 22 does not have 664 characters)
Attached is the script, a test Rhino file, my SystemInfo, the log, and a video showing how the script works.