How to modify referenced assemblies in a C# script component with another C# script component

Dear Experts,

I’m trying to figure out how i can modify referenced assemblies in a C# script component from within another C# script component.
Reason for this, is that together with Grasshopper I am also using an external software for which i have written some short C# scripts in Grasshopper.

The assemblies in my own written C# script are now only referencing to a specific version of the external software. This is what I would be able to modify, depending of which version of the external software I am using since the Namespaces, Classes etc. don’t usually change that much…

Modify (6.8 KB)

I have figured out how to get the C# scripts of the Grasshopper document, but the type I get is ScriptComponents.Component_CSNET_Script. How can I get the Namespace for this?

B r, Kristoffer


you must have ScriptComponents.gha referenced in the component.

    foreach(var obj in GrasshopperDocument.Objects)
      var script = obj as ScriptComponents.Component_AbstractScript;
      if ( script != null && script.NickName == "UniqueName" )
        switch ( version )
          case "1.0.0":
            path = "Path/to/version-1.0.0.dll";
          case "1.1.0":
            path = "Path/to/version-1.1.0.gha";
        if ( !script.ScriptSource.References.Contains(path) )
          script.ScriptAssembly = null;
1 Like


thanks for the reply and help.
I got it to work.(not as pretty as your solution, but it is working at least…)

Anyway, attached is the .gh file if anyone would find it helpful.

Modify (14.6 KB)