2.19.1 Rhino plugin fails loading - Avalonia missing (Rhino7 + Rhino8)

Just updated to 2.19.1 connector for Rhino

Getting this error in Rhino7:
image

And getting this error in Rhino8:
image
image

And in Grasshopper (Rh8):

Any clues?

Hey @Sonderwoods ,

Two possible reasons comes to my mind:

  • Can you check your DotNet Runtime > SetDotNetRunTime command should be set as “Default” in Rhino 8.
  • Do you have any other connectors installed? If yes, can you make sure their versions align with Rhino connector’s version?

Thanks Bilal,

Fails on both .Core and Default in SetDotNetRunTime .

Other connectors look like this:

image

Also tried wiping the folder

C:\Users\XXX\AppData\Roaming\McNeel\Rhinoceros\8.0\Plug-ins\SpeckleRhino2 (8dd5f30b-a13d-4a24-abdc-3e05c8c87143)\SpeckleConnectorRhino.rhp and reinstalling but no luck. I’m guessing the best clue is in the rhino 7 message about avalonia missing.

Uninstalling + Reinstalling rhino+gh plugins fixed for Rh7, but problem persists in Rh8.

Hey @Sonderwoods from this screenshot, it looks like there could be an old version of Speckle lingering around (v2.9.0):

image

Can you inspect your Rhino/GH plugins? Here’s a quick way to do it.

hi Matteo, heres my plugins in Rh7 (in gh that is, maybe rhino is diff?)

And in Rh8 we see the old SpeckleCore automatically jumping in (perhaps at Rh8 installation?)

Thanks for checking! So let’s tackle Rhino 8 as it seems Rhino 7 worked after a re-install.

To remove the old SpeckleCore, let’s find where it comes from first.
I should have this earlier, but this is an updated C# node that also outputs the location of each dll: Detecting multiple installation issues in Rhino / Grasshopper

Thanks Matteo,

Bingo!, I found out we’re referring to an old version in our inhouse plugin.

But even after updating references in our plugin i had issues. Ideally I could load the speckle libraries dynamically instead of shipping with our plugin. Need to investigate.

Yes, this is our recommended way to consume SpeckleCore and other dependencies - let us know if you have questions setting it up!

Thanks Matteo,

for now i just changed the “copy local” to false in the VS references of our grasshopper plugin, isnt that sufficient? best.

Yes, this should be enough assuming that Speckle gets loaded before you plugin calls any of its methods.
If Speckle is instead loaded by Rhino/Gh after you make any calls to it, you’ll get an error. If this is the case, you’d just need to force-load its assemblies beforehand.

Using an assembly resolver could be a solution: speckle-sharp/ConnectorRevit/ConnectorRevit/Entry/App.cs at e28f84e62b3582a135fbd292207ebdc6a9f4088e · specklesystems/speckle-sharp · GitHub

1 Like

Thanks, ending up with something like the below. Just missing a smart way of finding the relevant speckleDll. Any good suggestions?

public class DashboardsPlugin : Rhino.PlugIns.PlugIn
{
    public DashboardsPlugin()
    {
        Instance = this;
    }

    ///<summary>Gets the only instance of the DashboardsPlugin plug-in.</summary>
    public static DashboardsPlugin Instance
    {
        get;
        private set;
    }

    /// <summary>
    /// Called by Rhino when loading this plug-in.
    /// </summary>
    protected override Rhino.PlugIns.LoadReturnCode OnLoad(ref string errorMessage)
    {
        AppDomain.CurrentDomain.AssemblyResolve += OnAssemblyResolve;
        return Rhino.PlugIns.LoadReturnCode.Success;
    }

    static Assembly OnAssemblyResolve(object sender, ResolveEventArgs args)
    {
        Assembly a = null;

        var speckleAssembly = AppDomain.CurrentDomain.GetAssemblies().Where(o => o.FullName.Contains("SpeckleCore2")).FirstOrDefault();
        // cant find above as it obviously isnt loaded yet.

        foreach (var item in AppDomain.CurrentDomain.GetAssemblies())
        {
            Debug.WriteLine(item.FullName);
        }


        if (speckleAssembly == null) return null;
// it returns null now. Need a way to find the dll.

        if (File.Exists(speckleAssembly.Location))
        {
            a = Assembly.LoadFrom(speckleAssembly.Location);
        }

        return a;
    }
}

Update,

I got it to work and find the SpeckleCore2 dll, see below.
However when I have my own plugin loaded, the speckle window looks like this (no exceptions)

and when i disable my own plugin it works fine.

I tried to force load speckle and im correctly finding the dll below. But either i have to force load additional dlls (like everything speckle depends on?? ) OR I’m loading the dll too late and will have to call the loading somewhere else in my plugin

Code that finds the right dll and force loads:

 static Assembly OnAssemblyResolve(object sender, ResolveEventArgs args)
 {
     Assembly a = null;

     var speckleAssembly = AppDomain.CurrentDomain.GetAssemblies().Where(o => o.FullName.Contains("SpeckleCore2")).FirstOrDefault();

     if(speckleAssembly != null)
     {
         a = Assembly.LoadFrom(speckleAssembly.Location);
         return a;
     }
     // cant find above as it obviously isnt loaded yet.

     //foreach (var item in AppDomain.CurrentDomain.GetAssemblies())
     //{
     //    Debug.WriteLine(item.FullName);
     //}

     // mine lives in C:\Users\MyBeautifulName\AppData\Roaming\McNeel\Rhinoceros\8.0\Plug-ins\SpeckleRhino2(8dd5f30b - a13d - 4a24 - abdc - 3e05c8c87143)\SpeckleCore2.dll


     //App data folder:
     string appdata = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);

     string subfolder = Path.Combine(appdata, "McNeel", "Rhinoceros", $"{RhinoApp.Version.Major:0}.0", "Plug-ins");

     foreach (string speckleFolder in Directory.GetDirectories(subfolder))
     {
         if (speckleFolder.StartsWith("SpeckleRhino2"))
         {
             string speckleFile = Directory.GetFiles(speckleFolder, "SpeckleCore2.dll").FirstOrDefault();

             if (speckleFile != null)
             {
                 a = Assembly.LoadFrom(speckleFile);
                 return a;
             }
         }
     }


     return null;
 }

If your plugin works fine and the Speckle UI is blank, I don’t think the issue is related to the DLL loading order. Instead, there could be some other dependency mismatch or error thrown when Speckle starts…

The best solution here would be to debug the Speckle plugin and see if any exceptions are being thrown. You could also check if there’s anything in the logs %appdata%/Speckle/Logs/.

Also might give us some extra hints: what’s you plugin doing with Speckle? :smiley: