Using Visual Studio for Component Development

The objective of this tutorial is to demonstrate the process required to create a Visual Studio project such that you can develop Grasshopper components from this environment. While this mode of working requires certainly more elaborate initial preparation, it does pay back rather quickly because of the best in class editing capabilities as well as debugging and code modification while the application is running.

Project Structure

  1. Solution Generation: In Visual Studio, create a new C# class library project. Visual Studio will create for you a Solution folder and inside of it a Project folder with the name you specified (so you can host multiple projects within one solution).
  2. External References: In Windows Explorer, create a new folder inside the Solution folder named “References” and copy or hard-link inside this folder the  libraries seen below. This step is optional but simplifies software updates and/or synchronization between multiple computers through for example Dropbox, Google Drive or Windows One Drive.
    1. RhinoCommon.dll found in the system folder of your Rhino’s installation
    2. Grasshopper.dll and GH_IO.dll found in the folder of your Grasshopper installation.
    3. Jeneratiff.gha (rename to Jeneratiff.dll), Jeneratiff.gh8 and Jeneratiff.gh4 found in the installation folder.
  3. Import References: In Visual Studio / Project View, include all of the above libraries (right click on the References tree item) and in the Properties View (often seen in the panel right below) Turn Off local copy.
  4. User Settings: Create a text file in the Project folder named as “YourProjectName.csproj.user” and paste the following settings. This step is in order to ensure debugging works correctly. In the settings text file you need to replace the path with the location of your installation directory of Rhino’s main executable.

Project Source Code