Referencing in-use *.gha assembly in C# ScriptEditor

Hello,

I’ve got the following problem: I have got a plugin (*.gha with some more *.dlls) that is loaded in Grasshopper. Now I want to change some parameters that are not exposed via Grasshopper through the C# ScriptEditor. With the old “C# Script” component, I could simply add the assemblies via the “Manage Assemblies” option, including the GHA file.

In the new ScriptEditor, I have added the assemblies as below:

//r "C:\Users\xxx\AppData\Roaming\Grasshopper\Libraries\KUKAprcGH\KUKAprcGH.gha"
//r "C:\Users\xxx\AppData\Roaming\Grasshopper\Libraries\KUKAprcGH\KUKAprcCore.dll"

The script editor now complains referring to the *.gha file that “System.IO.FileLoadException: Assembly with same name is already loaded” which makes sense, as the library is in use within Grasshopper.

Simply renaming the file to *.dll and loading it did not change anything, as expected.

Is there any “native” way to load assemblies that are already in use by Grasshopper?
That thread seems to suggest that it should work, which it does not for me: How to manage assemblies in new C# editor?

@eirannejad: Is that still within your area?

Thank you!
Johannes

If you know assemblies are loaded, try:

// r "KUKAprcGH.gha"
// r "KUKAprcCore.dll"
2 Likes

Hello Ehsan,

That worked perfectly and is super nice, as it was always a pain to share C# script components with absolute paths pointing to my user directory.

I really appreciate it!
Best,
Johannes

1 Like

Absolutely. I’m glad you like it. :smiley: Thanks for the bug reporting and keep posting them please.