# How to ensure my Rhino Plugin loads the correct DLL?

**URL:** <https://discourse.mcneel.com/t/how-to-ensure-my-rhino-plugin-loads-the-correct-dll/46747>\
**Category:** Rhino Developer\
**Created:** [August 18, 2017, 8:59am UTC](https://discourse.mcneel.com/t/how-to-ensure-my-rhino-plugin-loads-the-correct-dll/46747 "2017-08-18T08:59:31Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Goswin](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/goswin/32/486365_2.png) [@Goswin](https://discourse.mcneel.com/u/Goswin)\
**Post date:** [August 18, 2017, 8:59am UTC](https://discourse.mcneel.com/t/how-to-ensure-my-rhino-plugin-loads-the-correct-dll/46747/1 "2017-08-18T08:59:31Z")

</div>

My Rhino plugin seems to be loading an older version of a .Net DLL that was part of another plugin installation.  
I only get this error on a PC where this older plugin is installed.  
I get a System.MissingMethodException at runtime. (during compilation the method is there)  
I have [the current version](https://www.nuget.org/packages/FSharp.Compiler.Service) in the same folder as the rhp file.  
I used reflection to see the assembly path. It shows the path in the same folder as the rhp. Still i get a method not found exception.  
When starting the WPF app standalone instead of hosted in Rhino 5 it works fine.

---

<div class="post-metadata">

**Author:** ![dale](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/dale/32/685184_2.png) [@dale](https://discourse.mcneel.com/u/dale)\
**Post date:** [August 25, 2017, 4:22pm UTC](https://discourse.mcneel.com/t/how-to-ensure-my-rhino-plugin-loads-the-correct-dll/46747/2 "2017-08-25T16:22:16Z")

</div>

Hi Goswin,

Can you post some code that demonstrates how you are loading the assembly?

Can I assume you are not doing something like this?

```auto
Assembly SampleAssembly;
SampleAssembly = Assembly.LoadFrom("c:\\Sample.Assembly.dll");

```

– Dale

---

<div class="post-metadata">

**Author:** ![Goswin](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/goswin/32/486365_2.png) [@Goswin](https://discourse.mcneel.com/u/Goswin)\
**Post date:** [August 28, 2017, 8:49am UTC](https://discourse.mcneel.com/t/how-to-ensure-my-rhino-plugin-loads-the-correct-dll/46747/3 "2017-08-28T08:49:58Z")

</div>

Hi Dale,  
I just reference FSharp.Compiler.Service via Nuget. The dll gets copied into the output directory on building. (same folder as the rhp)  
I am not sure how to use `assem = Assembly.LoadFile(path)`. I tried this line but the wrong assembly seems to be loaded already. Do I have to use the methods on `assem` via reflection ?

---

<div class="post-metadata">

**Author:** ![stevebaer](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/stevebaer/32/473567_2.png) [@stevebaer](https://discourse.mcneel.com/u/stevebaer)\
**Post date:** [August 29, 2017, 4:23pm UTC](https://discourse.mcneel.com/t/how-to-ensure-my-rhino-plugin-loads-the-correct-dll/46747/5 "2017-08-29T16:23:34Z")

</div>

Rhino only allows a single assembly of a given name to be loaded in the process. When the .NET framework tells Rhino that is needs to find an assembly, Rhino walks through the list of directories where every plug-in is installed and attempts to find the DLL in that location. I’m guessing Rhino is looking in the older plug-in directory and loading the fsharp DLL from there.

I don’t currently have a good fix for this.

---

<div class="post-metadata">

**Author:** ![Goswin](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/goswin/32/486365_2.png) [@Goswin](https://discourse.mcneel.com/u/Goswin)\
**Post date:** [August 29, 2017, 5:21pm UTC](https://discourse.mcneel.com/t/how-to-ensure-my-rhino-plugin-loads-the-correct-dll/46747/6 "2017-08-29T17:21:13Z")

</div>

Thanks Steve,  
Can I get access to the list of directories that Rhino is walking ? For better debugging.  
When I check the assembly location via reflection on one of its classes it oddly shows the correct one in the same folder as the rhp. But still the expected method is not found.

---

<div class="post-metadata">

**Author:** ![stevebaer](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/stevebaer/32/473567_2.png) [@stevebaer](https://discourse.mcneel.com/u/stevebaer)\
**Post date:** [August 29, 2017, 5:56pm UTC](https://discourse.mcneel.com/t/how-to-ensure-my-rhino-plugin-loads-the-correct-dll/46747/7 "2017-08-29T17:56:24Z")

</div>

Rhino.Runtime.HostUtils.GetAssemblySearchPaths should give you the list

---

<div class="post-metadata">

**Author:** ![Goswin](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/goswin/32/486365_2.png) [@Goswin](https://discourse.mcneel.com/u/Goswin)\
**Post date:** [September 7, 2017, 11:25am UTC](https://discourse.mcneel.com/t/how-to-ensure-my-rhino-plugin-loads-the-correct-dll/46747/8 "2017-09-07T11:25:57Z")

</div>

Thanks Steve,  
I removed some old plugins. Now I do not see another dll of the same name in GetAssemblySearchPaths. I also used [FusionLogging](https://stackoverflow.com/questions/255669/how-to-enable-assembly-bind-failure-logging-fusion-in-net) and did not see any other unwanted FSharp Compiler Assemblies. Still I get a **method not found Exception**. So the reason for this must be something else. On my Win 10 laptop everything is OK. Does RH5 on Win 7 restrict .Net plugins in any way? Is Net 4.5 supported ?

---

<div class="post-metadata">

**Author:** ![nathanletwory](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/nathanletwory/32/482880_2.png) [@nathanletwory](https://discourse.mcneel.com/u/nathanletwory)\
**Post date:** [September 7, 2017, 12:52pm UTC](https://discourse.mcneel.com/t/how-to-ensure-my-rhino-plugin-loads-the-correct-dll/46747/9 "2017-09-07T12:52:46Z")

</div>

Caveat: I work in Rhino WIP.

I have a Grasshopper plug-in written in F#. That works just fine. I’ll have to try a v6 plug-in with the F# compiler services too. Is there anything specific you are doing? Or is it already enough to just instantiate a service?

---

<div class="post-metadata">

**Author:** ![Goswin](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/goswin/32/486365_2.png) [@Goswin](https://discourse.mcneel.com/u/Goswin)\
**Post date:** [September 7, 2017, 4:23pm UTC](https://discourse.mcneel.com/t/how-to-ensure-my-rhino-plugin-loads-the-correct-dll/46747/10 "2017-09-07T16:23:07Z")

</div>

Nathan, Is there a way in VS to build my plugin vor rh5 and rh6 simultaneously ?

---

<div class="post-metadata">

**Author:** ![stevebaer](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/stevebaer/32/473567_2.png) [@stevebaer](https://discourse.mcneel.com/u/stevebaer)\
**Post date:** [September 7, 2017, 4:37pm UTC](https://discourse.mcneel.com/t/how-to-ensure-my-rhino-plugin-loads-the-correct-dll/46747/11 "2017-09-07T16:37:22Z")

</div>

> [@Goswin](#):
>
> Is there a way in VS to build my plugin vor rh5 and rh6 simultaneously

Your V5 plug-in should load into V6 as long as all of the RhinoCommon functions you call still exist in V6

---

<div class="post-metadata">

**Author:** ![stevebaer](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/stevebaer/32/473567_2.png) [@stevebaer](https://discourse.mcneel.com/u/stevebaer)\
**Post date:** [September 7, 2017, 4:45pm UTC](https://discourse.mcneel.com/t/how-to-ensure-my-rhino-plugin-loads-the-correct-dll/46747/12 "2017-09-07T16:45:19Z")

</div>

Maybe test with this python script to see where the fsharp assembly is coming from…

```auto
import System
assemblies = System.AppDomain.CurrentDomain.GetAssemblies()
for assembly in assemblies:
    try:
        if assembly.FullName.ToUpper().Contains("FSHARP"):
            print assembly.Location
    except:
        pass

```

---

<div class="post-metadata">

**Author:** ![nathanletwory](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/nathanletwory/32/482880_2.png) [@nathanletwory](https://discourse.mcneel.com/u/nathanletwory)\
**Post date:** [September 7, 2017, 6:05pm UTC](https://discourse.mcneel.com/t/how-to-ensure-my-rhino-plugin-loads-the-correct-dll/46747/13 "2017-09-07T18:05:47Z")

</div>

With some manually fiddling around in your csproj file you should be able to get configurations that support both. As Steve says the v5 RhinoCommon plug-in should load into v6 without problems, though.

---

<div class="post-metadata">

**Author:** ![Goswin](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/goswin/32/486365_2.png) [@Goswin](https://discourse.mcneel.com/u/Goswin)\
**Post date:** [September 8, 2017, 9:30am UTC](https://discourse.mcneel.com/t/how-to-ensure-my-rhino-plugin-loads-the-correct-dll/46747/14 "2017-09-08T09:30:59Z")

</div>

This is the error I get when I load it in RH6:  
 ![2017-09-08_112755](https://global.discourse-cdn.com/mcneel/uploads/default/original/3X/1/4/14af575ba3888eb70ee0a3bd29a4bbec84819e4f.jpg)  
@nathanletwory I am building an FSharp scripting editor for Rhino. So I need the FSharp.Compiler.Service.dll  
@stevebaer running your script does only show the desired FSharp dlls. not old ones. I tested it on another win7 PC in the office wit Rhino5. it worked fine there. So my suspicion is that the MissingMethodException is caused by something else.

---

<div class="post-metadata">

**Author:** ![nathanletwory](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/nathanletwory/32/482880_2.png) [@nathanletwory](https://discourse.mcneel.com/u/nathanletwory)\
**Post date:** [September 8, 2017, 11:25am UTC](https://discourse.mcneel.com/t/how-to-ensure-my-rhino-plugin-loads-the-correct-dll/46747/15 "2017-09-08T11:25:22Z")

</div>

I tried in V6 a simple (empty) plug-in that instantiates an FSharpChecker.

```
FSharpOption<int> ps = new FSharpOption<int>(10);
FSharpOption<bool> b = new FSharpOption<bool>(false);
FSharpChecker checker = FSharpChecker.Create(ps, b, b, null);

```

That works just fine.

Is it possible for you to boil down to a test plug-in that does the minimal steps to reproduce the error?

/Nathan

---

<div class="post-metadata">

**Author:** ![rolf](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/rolf/32/516076_2.png) [@rolf](https://discourse.mcneel.com/u/rolf)\
**Post date:** [February 22, 2022, 3:22pm UTC](https://discourse.mcneel.com/t/how-to-ensure-my-rhino-plugin-loads-the-correct-dll/46747/16 "2022-02-22T15:22:12Z")

</div>

Hey Steve,

I have the same issue with 3 plugins created by my office that share the same library (.dll). I would like to make sure the most recent version of the library is loaded, but the problem of this thread still persists. Has there been any development regarding this loading process? Is there any solution besides making three copies of the same library with a slightly different name?

I will keep searching for different threads regarding this problem.

Any helps is appreciated!

---

<div class="post-metadata">

**Author:** ![stevebaer](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/stevebaer/32/473567_2.png) [@stevebaer](https://discourse.mcneel.com/u/stevebaer)\
**Post date:** [February 22, 2022, 4:08pm UTC](https://discourse.mcneel.com/t/how-to-ensure-my-rhino-plugin-loads-the-correct-dll/46747/17 "2022-02-22T16:08:18Z")

</div>

Please explain a little more about what the issue is that you are seeing. This thread is four years old and involves libraries installed by nuget, so I’m not entirely sure what you are experiencing is the same issue.

---

<div class="post-metadata">

**Author:** ![rolf](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/rolf/32/516076_2.png) [@rolf](https://discourse.mcneel.com/u/rolf)\
**Post date:** [February 23, 2022, 8:53am UTC](https://discourse.mcneel.com/t/how-to-ensure-my-rhino-plugin-loads-the-correct-dll/46747/18 "2022-02-23T08:53:28Z")

</div>

Aah you might be right Steve, I’ll try to explain it thoroughly.

At my office, we created 3 plug-ins that are ‘installed’ at the following location C:\Users\rolf\_\AppData\Roaming\McNeel\Rhinoceros\7.0\Plug-ins  
All three plug-ins use the same Library.dll assembly that we developed which contains common methods and classes. All 3 plug-ins are updated frequently but NOT always at the same time. Sometimes including new additions in our library.dll. _Note:_ We try to maintain old methods and classes in the library for compatibility purposes. _Note:_ the user sometimes uses an old version of the first plugin, a slightly newer one of the second, and the newest version of the third plugin because of backward compatibility reasons, bugs, etc.

As you mentioned in this thread, Rhino only allows a single assembly of a given name to be loaded in the process. We noticed that depending on which plugin is installed first determines which version of the library.dll is loaded. Most likely this is what you meant with ‘Rhino walks through the list of directories where every plug-in is installed’ Preferably we would like the most recent version of the library.dll to always be loaded, which is not always the first one to be installed. Perhaps we could force the plugin in (with the newest library) to be loaded first if we know how plugin loading order is exactly determined. Any help is welcome!

---

<div class="post-metadata">

**Author:** ![stevebaer](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/stevebaer/32/473567_2.png) [@stevebaer](https://discourse.mcneel.com/u/stevebaer)\
**Post date:** [February 23, 2022, 10:29pm UTC](https://discourse.mcneel.com/t/how-to-ensure-my-rhino-plugin-loads-the-correct-dll/46747/19 "2022-02-23T22:29:43Z")

</div>

What if you eliminated the Library.dll completely and had all three plug-ins reference the same shared source files?

---

<div class="post-metadata">

**Author:** ![rolf](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/rolf/32/516076_2.png) [@rolf](https://discourse.mcneel.com/u/rolf)\
**Post date:** [February 28, 2022, 2:11pm UTC](https://discourse.mcneel.com/t/how-to-ensure-my-rhino-plugin-loads-the-correct-dll/46747/20 "2022-02-28T14:11:21Z")

</div>

Thanks Steve, could you clarify this direction? We are not aware of a method that allows you to reference shared source files without the need for dlls or combining the plugins in a single project. Would there be any other way to force the latest version of the DLL to be loaded?

_Note:_ that our plugins contain both components for Grasshopper and Rhino.

---

<div class="post-metadata">

**Author:** ![rolf](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/rolf/32/516076_2.png) [@rolf](https://discourse.mcneel.com/u/rolf)\
**Post date:** [March 21, 2022, 2:43pm UTC](https://discourse.mcneel.com/t/how-to-ensure-my-rhino-plugin-loads-the-correct-dll/46747/21 "2022-03-21T14:43:50Z")

</div>

We decided, for now, to always install all three installers built at the same time from the same branch to prevent any .dll issues. This is definitely not ideal, so would love to hear about this option you suggested @stevebaer

[Next page](https://discourse.mcneel.com/t/how-to-ensure-my-rhino-plugin-loads-the-correct-dll/46747.md?page=2)
