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

**URL:** <https://discourse.mcneel.com/t/how-to-modify-referenced-assemblies-in-a-c-script-component-with-another-c-script-component/93594>\
**Category:** Grasshopper\
**Tags:** grasshopper\
**Created:** [December 13, 2019, 11:32am UTC](https://discourse.mcneel.com/t/how-to-modify-referenced-assemblies-in-a-c-script-component-with-another-c-script-component/93594 "2019-12-13T11:32:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kristoffer.berglund](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/kristoffer.berglund/32/192440_2.png) [@kristoffer.berglund](https://discourse.mcneel.com/u/kristoffer.berglund)\
**Post date:** [December 13, 2019, 11:32am UTC](https://discourse.mcneel.com/t/how-to-modify-referenced-assemblies-in-a-c-script-component-with-another-c-script-component/93594/1 "2019-12-13T11:32:21Z")

</div>

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…

 ![image](https://global.discourse-cdn.com/mcneel/uploads/default/original/3X/b/f/bffe98aa4721d88e6919f932e4888d8025f644dd.png) [Modify assemblies.gh](https://discourse.mcneel.com/uploads/short-url/trqh8YpH8iwc6Q2QQRQDWJq6MvC.gh) (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

---

<div class="post-metadata">

**Author:** ![kitjmv](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/kitjmv/32/510467_2.png) [@kitjmv](https://discourse.mcneel.com/u/kitjmv)\
**Post date:** [December 13, 2019, 12:11pm UTC](https://discourse.mcneel.com/t/how-to-modify-referenced-assemblies-in-a-c-script-component-with-another-c-script-component/93594/2 "2019-12-13T12:11:35Z")

</div>

Hello

you must have ScriptComponents.gha referenced in the component.

```cs
    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";
            break;
          case "1.1.0":
            path = "Path/to/version-1.1.0.gha";
            break;
        }
        if ( !script.ScriptSource.References.Contains(path) )
        {
          script.ScriptSource.References.Add(path);
          script.ScriptAssembly = null;
          //script.ExpireSolution(true)
        }
      }

```

---

<div class="post-metadata">

**Author:** ![kristoffer.berglund](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/kristoffer.berglund/32/192440_2.png) [@kristoffer.berglund](https://discourse.mcneel.com/u/kristoffer.berglund)\
**Post date:** [December 16, 2019, 10:01am UTC](https://discourse.mcneel.com/t/how-to-modify-referenced-assemblies-in-a-c-script-component-with-another-c-script-component/93594/3 "2019-12-16T10:01:18Z")

</div>

Hello,

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 assemblies.gh](https://discourse.mcneel.com/uploads/short-url/uigEU2MCy51iyneMJ3qdj8Gmx1e.gh) (14.6 KB)
