Unable to load plugin: initialization failed

Hi,

I’m creating a rhino plugin. Recently after making some major changes to my program I get a error when I try to open rhino:

image

This error does not come when i open the plugin from visual studio with in the debugging mode, so it is really hard to find what causes it.

Any ideas where I should start?

with best regards Matti

1 Like

Sounds like possibly conflicting registry keys. I’d go and remove all registry keys for your plug-in, then reload the plug-in in a fresh Rhino instance.

Is your plugin using other dll’s? If so, make sure they can be found and that their configuration (debug/release) match the configuration of the plugin.

Hi. Thanks for the answers. I tried removing the registry keys. I found only one registry key and removed it and tried reloading the plugin but it didn’t help. I think the problem have something to do with the external dll’s as @menno said. I think it started when I moved all my external dll’s to my project folder (including rhinocommon and grasshopper) I did this since the project is in git and my collegue had problems since his dll’s were not in the same location as my. I tried changing the references back to the original location of the dll’s but it didn’t help with the problem.

I have one external class library that i have created my self and the configuration of that should be the same as my project. For the other external dll’s I cannot say (Rhinocommon grasshopper etc.)

Update.

I noticed that the rhino console gives this “extra” warning when the initialization failed comes up:

So it seems it cannot find the plugin class any ideas why?

@stevebaer correct me if I’m wrong, but Rhino 6 will not load Rhino_DotNet plug-ins. However, you can still use your old plug-in soruce code. Just build a RhinoCommon plug-in project, add a reference to Rhino_DotNet.dll and then copy the code from your old plug-in to the new project.

Does this help?

– Dale

I’ve found on a similar note (sorry if this is hijacking the thread), that having multiple versions of a plugin installed can cause issues too.

It creates a new folder for each version of the plugin in “%appdata%\McNeel\Rhinoceros\6.0\Plug-ins<plugin>”. I’d assume that only one of these is intended to be loaded, but somehow I (and users) often get initialization errors when there are superseded versions there. This is even with the dependencies ILMerged into a single .rhp, so it doesn’t seem likely that there’d be a dependency mixup. Removing the older versions causes the plugin to load correctly.

I haven’t yet been able to extract enough debugging information to figure out why this is, so any advice would be welcome.

1 Like

Hi @dale, I’m still using Rhino 5. Is there a same problem with that version of rhino? I think anyways I will try to create a new project just to try to locate the problem.

I finally found the problem:

I was loading a csv file to my program with the code:

string workingDirectory = System.IO.Directory.GetCurrentDirectory();
string projectDirectory = Directory.GetParent(workingDirectory).Parent.FullName;
projectDirectory = projectDirectory + "\\RhinoProject";
StreamReader sr = new StreamReader(projectDirectory + "\\SupportFiles\\CrossSectionValues.csv");`

Didn’t understand that the working directory is not same when the rhp file is loaded by rhino… silly me :slight_smile:.

Thanks everyone for the help

-Matti

You should always check for exceptions, especially when doing file I/O

2 Likes

And you should likely wrap your streaming reader in a using statement so it gets disposed and releases the file.

using (Stream sr = new StreamReader(dir)) 
{
}
2 Likes