Visual Studio not executing code changes

Hi,

This question might be more appropriate for StackOverflow, but I was just wondering if someone here recognizes this issue and how to fix it.

I am working with a Visual Studio solution, that defines a number of custom GrassHopper components (inheriting from Grasshopper.Kernel.GH_Component).

For one of these implementations, I am trying to debug and add some code to an already existing public override void AddedToDocument function.

Specifically, I added a breakpoint to the opening bracket of the function, and I have added a couple of lines (2 blank lines, 1 lines containing a call System.Diagnostics.Debug.WriteLine("hooray!");.

When I start debugging the solution, Rhino opens, and I can open Grasshopper. When I add the custom node to the canvas, the breakpoint hits. So far so good.

However … when I single-step through the code with F10, then I notice that Visual Studio doesnt actually execute my added code. It behaves like the added code is not even there. Visual Studio seems to be executing the lines as if there has not been any code change, as in that it jumps over lines where previously was an empty line.

I am completely in the dark on how to fix this.

My assumption is that somehow GrassHopper is not working with the new build, and it is still executing the old build. I am not sure however.

Does anybody have an idea and any advice on how to fix this? Much appreciated!

I wonder if codes are actually applied by Hot Reload (the little fire icon besides Run, the play button).

I did not use Hot Reload. I did however try things like:

  • Close VS
  • Delete bin and obj folders
  • Reopen VS
  • Clean Solution
  • Rebuild Solution
  • Restart debugging

I would assume that this process forces a rebuilding of the .gha, but it seems not to get attached to the Grasshopper process running in Rhino…

I would assume that this process forces a rebuilding of the .gha, but it seems not to get attached to the Grasshopper process running in Rhino…

Come to think of it, this might be the cause. I think the question is:
How do I link my Rhino/Grasshopper debugging session to the newly built .gha file?

Because, I already have an existing build of this custom component linked in my Special Folders > Components Folder. Somehow I need to tell GrassHopper to use the newly built debug version. How do you set this up normally ?

Oh. I think Grasshopper may not load the latest file. Use GrasshopperDeveloperSetting to add the bin folder instead of putting GHA in Libraries.

2 Likes

Use GrasshopperDeveloperSetting to add the bin folder instead of putting GHA in Libraries.

Fixed!

Thanks a lot. I had some trouble finding out where GrasshopperDeveloperSetting was accessed but that is by the Rhino command line, and then I just added the path to the debug folder of my component, containing the new built .gha file. And it works.

Thanks again!