Closed DanielAbalde closed 3 years ago
I just ran the sample project with no modifications and everything worked.
The two lines of code
var pluginObject = Rhino.RhinoApp.GetPlugInObject("Grasshopper") as Grasshopper.Plugin.GH_RhinoScriptInterface;
pluginObject.RunHeadless();
can be removed since at this point GH is smart enough to know that it is running in a headless environment. Those lines were only necessary in very early service releases of Rhino 7
Thanks for the help @sbaer.
TL;TR: skip to last paragraph.
I started from scratch and in the debug output I can see:
Begin SendAsync
Before RetryLoop
Before SendHttpRequestAsync
Begin SendHttpRequestAsync
'RunGrasshopper.exe' (CLR v4.0.30319: RunGrasshopper.exe): Loaded 'C:\Users\< my personal path>\Peacock3d\Peacock-Rhinoceros\Build\bin\Grasshopper.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'RunGrasshopper.exe' (CLR v4.0.30319: RunGrasshopper.exe): Loaded 'C:\Users\< my personal path>\Peacock3d\Peacock-Rhinoceros\Build\bin\GH_IO.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
Exception thrown: 'System.MissingMethodException' in RunGrasshopper.exe
An unhandled exception of type 'System.MissingMethodException' occurred in RunGrasshopper.exe
Method not found: 'Void Grasshopper.Plugin.GH_RhinoScriptInterface.RunHeadless()'.
It seems that Grasshopper.dll and GH_IO.dll is being referenced from one of my plugins folder (using Rhino 6) instead from the Rhino installation! How this can happen?
It is even more random, I tried deleting those libraries from \Peacock3d\Peacock-Rhinoceros\Build\bin\, and I run the solution, it works fine. I run it again, and it fails!
Exception thrown: 'System.NullReferenceException' in NGonGh.gha
Rhino.RhinoDoc.ActiveDoc.**get** returned null.
I run it again and it works. I run it again and same error. And so on, very weird... Visual Studio is not consistent for some reason.
👇 I don't know why these GH libraries have been referenced in the wrong folder and with the wrong version of GH (for rh6). Maybe it was a VS error for using the cache, I don't know, or maybe you have some vs project instructions to reference these libraries, in that case maybe it needs a revision, or if it doesn't exist maybe it's convenient to include it.
Thanks!
Hi @fraguada,
I am not able to make work your sample project:
https://github.com/mcneel/rhino-developer-samples/blob/7/rhino.inside/dotnet/SampleRunGrasshopper/Program.cs
I have the nuget libraries and using .NET 4.8.![image](https://user-images.githubusercontent.com/14053237/120653986-2376b080-c479-11eb-8363-3ee3a5687a10.png)
But when I run I got:
System.MissingMethodException: 'Method not found: 'Void Grasshopper.Plugin.GH_RhinoScriptInterface.RunHeadless()'.'
at https://github.com/mcneel/rhino-developer-samples/blob/579bcefec8d1ae1f0fa437d8f8a7c7529693e120/rhino.inside/dotnet/SampleRunGrasshopper/Program.cs#L39 For some reason looks like is referencing other Grasshopper.dll version, so I tried subscribing toAppDomain.CurrentDomain.AssemblyResolve
to load the Grasshopper.dll from the Rhino 7 Plug-ins folder, but after that in the same code line I gotSystem.NullReferenceException: 'Object reference not set to an instance of an object.'
.Could you or someone look into this please?
Thanks.