Assembly conflict only when running Inside Revit

I am facing a problem resolving an assembly for a Gh plugin when running inside revit.

The gh plugin is using a specific version of Newtonsoft.Json, it works fine when loaded in Rhino WIP.
But when its running through Rhino Inside Revit, I am getting assembly conflict with an older version.

How are assemblies being resolved by grasshopper when running inside Revit?

Do I have to resolve conflicts with Revit assemblies myself in a gh_assemblypriority instance?

How do you know it’s a conflict with Newtonsoft.Json? Rhino ships with a modified version of this assembly so there should not be any conflicts

Hi Ehsan, this is the error message
“Could not load type ‘Newtonsoft.Json.Serialization.ISerializationBinder’ from assembly ‘Newtonsoft.Json, Version=, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed’.”

The version the plugin is using is higher than the logged version. And as I mentioned its also working normally if loaded in Rhino 7 outside revit.

1 Like

Okay so the GH plugin is using their own Newtonsoft.Json. This is going to be challeging. Try to go the the plugin installation folder and the (backup) remove the Newtonsoft.Json.dll in there. This should force the plugin to use whatever Newtonsoft.Json that is already loaded.

Hi Ehsan, that will not resolve the issue. I am using a specific class only available in 12.0+, the ISerializationBinder. Any other workarounds? :sweat_smile:

Just to know if the conflict is with the one that comes with Revit.

Could you please replace the one that ships with Revit by your 12.0 one?
Is at C:\Program Files\Autodesk\Revit XXXX\NewtonSoft.Json.dll.

@kike hi Kike, yes, once I did that it worked fine.


Is there any solution for this though? as I don’t consider this as a viable solution specially for the deployment of the plugin.

Where is your NewtonSoft.Json.dll 12.0 version deployed right now?
Is there any difference if you reference NewtonSoft using Specific Version = True?

Its sitting next to the .gha file in a folder inside %appdata%/Grasshopper/libraries

I googled a bit as this property wasn’t there, but this option is by default True when you are using Nuget, which I am.

Okay, I just found out that in Rhino 7 the dll I build in the plugin folder is actually not loaded.
This image shows the modules loaded while running in Rhino 7

While this one shows the one loaded when running inside Revit

The two in the first image, where the plugin successfully works, are also loaded when running in Revit, but for some reason the resolved one ends up being the version!

BTW if anyone faces the same problem, specifying the full-name of the assembly and loading it in a class derived from GH_AssemblyPriority resolved the issue.

1 Like