What’s the purpose of Grasshopper and RhinoCommon NuGet packages? I tried to use them but if I start a Rhino process, use GH_IO to read the script and then try to create a new GH_Document I get the error “Unable to load DLL ‘rhcommon_c’”. It seems I can compile the code with the NuGet packages just fine but miss some runtime dependencies. If I reference the local DLLs in the Rhino installation instead of the NuGet packages and run the same code it works fine.
As a general question what is the right way to use the the Grasshopper and RhinoCommon DLLs at runtime?
You are right, the NuGet packages just contains the required libraries for compiling and building the third party plugins but not enough to run those builds. The are many advantages of using NuGet packages rather than directly referencing the RhinoCommon.dll (and other dlls) that comes with the standard Rhino installation on one’s computer:
You can develop and build plugins on a computer that does not have Rhino installed (even though testing still requires full Rhino of course)
if you want to compile your code to run in an older version Rhino/Grasshopper, you just need to download the older version of the NuGet packages (rather than having to install an older version of Rhino on your computer just to get the old RhinoCommon.dll and Grasshopper dll)
These days, it is very common to share code projects (via an online repo such as GitHub), using NuGet packages allows code being cloned on different machines to get the referenced libraries set up correctly (otherwise, the cloned code on each machine must have the dependencies set up/corrected manually)
The point above is particularly true if your projects have lots of dependencies, which in turn depends on other dependencies, and so on. Without a package management system like NuGet, it will quickly become a night mare to get all those dependencies (i.e. downloading them from various websites, etc) and adding them to the code manually (e.g. when you work on a shared project)
Of course, if you build a plugin for you to use on your own, and only meant to be run on your own computers, then you can just directly referencing the dlls that come with the Rhino installation on your own computer. The benefit of using NuGet will be much less significant.