Detect if Grasshopper Instance is RhinoCompute or not

I’m working on a plugin that writes out a file as it is loaded during Grasshopper initial boot up (via a “PriorityLoad()” method). However, I noticed that on some computers, it writes two files!

After a lot of debugging, I traced this to Hops, specifically the “Launch Local Rhino Compute” option that Hops adds to the “Preferences” :arrow_right: “Solver” menu. It seems like a second copy of Grasshopper launches in the background, which includes loading the plugin and therefore writing a second file.

So my question is… Is there any way to detect whether the current Grasshopper context is being related within a Rhino Compute instance?

I actually solved it, leaving this here for others:

This code

Rhino.Runtime.HostUtils.RunningAsRhinoInside;
Rhino.Runtime.HostUtils.RunningInRhino; 
string processName = "";
System.Version processVersion;
Rhino.Runtime.HostUtils.GetCurrentProcessInfo(out processName, out processVersion);

Will result in these values for the “real” Grasshopper load:

  "RunningAsRhinoInside": false,
  "RunningInRhino": true,
  "ProcessName": "Rhino",
  "ProcessVersion": "7.18.22124.3001"

But results in this for the “Rhino Compute” Grasshopper load:

  "RunningAsRhinoInside": true,
  "RunningInRhino": true,
  "ProcessName": "compute.geometry",
  "ProcessVersion": "1.0.0.0"