Can't find C# Grasshopper component in Visual Studio when starting Rhino

These are the usual things that need to happen if you want to Debug a plug-in assembly using Visual Studio:

  1. VS needs to output a file called <MyPluginName>.gha instead of <MyPluginName>.dll. The plugin wizards will usually take care of this, but if that’s not working you need to set up a post-build event by hand to rename the dll file.
  2. This gha file will by default be in either the \bin\Debug\ or bin\Release\ folder. I actually don’t like having two versions of the same project next to each other with different states, so I change my build flavour output directory to just be \bin\ for both Debug and Release builds. I do not know if the VS wizards also sets this up this way.
  3. Now when you build/compile your project you should get a new <MyPluginName>.gha file somewhere inside \bin\? with a current timestamp.
  4. Next up Grasshopper needs to learn that it is supposed to load this gha file. The easiest way to set this up is to run the _GrasshopperDeveloperSettings command in Rhino and add your bin folder to the list of folders in which Grasshopper looks:
  5. Also make sure that Memory Load *.GHA... is unchecked, or breakpoints won’t work.
  6. Lastly, you must make sure that when you begin debugging, Visual Studio knows that it’s supposed to start Rhino. This is taken care of by the wizard, but you can also set the start action via the VS UI:

You should now be set to debug your project. Put a breakpoint on the first line of the constructor of your component and start the debugger. Rhino should load. Run the _Grasshopper command and your breakpoint should turn from an open circle into a closed disk once your plugin gets loaded. It should also hit the breakpoint as all components are constructed once during load.

2 Likes