getting a run-time error when binding a transitive dependency

03-09-2020 11:06 AM
New Contributor

Hi All,

I've just started developing on the ArcGis Pro SDK and I'm running into an issue when binding transitive dependencies.

  • My add-in uses the Newtonsoft package (v12.3)
  • I am also using GeoJson.Net (v1.2.15), which is compiled against Newtonsoft v10
  • In my test module's app.config I have a binding redirect as follows

       <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
        <bindingRedirect oldVersion="" newVersion="" />

The test module works fine & the binding redirect is found and works expected (see attached binding log)

When running in my ArcGis module the binding fails (also see attached)

Has anyone had experience in solving this problem? This is the second time I've hit this problem and I just worked around it before, but now I'd like to get to the bottom of the issue,

Any help much appreicated,

Rupert Lloyd


0 Kudos
1 Reply
Esri Regular Contributor

Hi Rupert,

Pro application (ArcGISPro.exe) does not use the binding redirect you have used in your add-in.

The best way to solve your issue is to resolve the Pro assembly path from your module - this will allow your add-in to use the Newtonsoft from Pro's bin folder.

So in your Module's Initialize override - 

 private static string _arcgisProPath = @"C:\Program Files\ArcGIS\Pro\"; //Get install path from registry
    public static Assembly ResolveProAssemblyPath(object sender, ResolveEventArgs args)
      string assemblyPath = Path.Combine(_arcgisProPath, "bin", new AssemblyName(args.Name).Name + ".dll");
      if (!File.Exists(assemblyPath)) return null;
      Assembly assembly = Assembly.LoadFrom(assemblyPath);
      return assembly;

 protected override bool Initialize()
      //Resolve ArcGIS Pro assemblies.
      AppDomain currentDomain = AppDomain.CurrentDomain;
      currentDomain.AssemblyResolve += new ResolveEventHandler(ResolveProAssemblyPath);
      return base.Initialize();



0 Kudos