Our addin cannot load `Newtonsoft.Json.dll` due to error in Inventor's app.config

Our addin cannot load `Newtonsoft.Json.dll` due to error in Inventor's app.config

scharrerVHKNR
Explorer Explorer
484 Views
3 Replies
Message 1 of 4

Our addin cannot load `Newtonsoft.Json.dll` due to error in Inventor's app.config

scharrerVHKNR
Explorer
Explorer

Hello Inventor dev community,

 

we are having a problem with an Inventor addin we are developing using the .NET Inventor API.

 

Our addin tries to load `Newtonsoft.Json.dll` version 6, which we ship together with our addin.

However, Inventor ships its own (newer) version of this DLL in its application folder:

 

C:\Program Files\Autodesk\Inventor 2022\Bin\Newtonsoft.Json.dll

 

Inventor also defines a .NET `bindingRedirect` to this newer DLL version in its `app.config` file:

 

C:\Program Files\Autodesk\Inventor 2022\Bin\Inventor.exe.config

 

 

This is all fine, except that in certain Inventor versions, the `app.config` points its `bindingRedirect` to a different DLL version than the DLL that Inventor actually provides:

 

Inventor 2022: `bindingRedirect` to DLL version 10, and ships DLL version 10 --> OK.

Inventor 2022.3.1: `bindingRedirect` to DLL version 10, but ships DLL version 12 --> ERROR!

Inventor 2022.4: `bindingRedirect` to DLL version 10, but ships DLL version 12 --> ERROR!

Inventor 2022.5: `bindingRedirect` to DLL version 10, but ships DLL version 12 --> ERROR!

Inventor 2023: `bindingRedirect` to DLL version 12, and ships DLL version 12 --> OK.

 

What happens in the Inventor versions with the mismatch, is that .NET sees the `bindingRedirect`, and therefore flat-out refuses to load our addin's version 6 of the DLL, and instead goes looking for a version 10 - but then can't find this version anywhere. So we get a `FileNotFoundException`, and our addin becomes non-functional.

 

Is there any possible valid reason for some Inventor versions have this DLL version mismatch?

It seems like a bug to me, like the Inventor devs updated the DLL but forgot to update their `app.config` accordingly.

 

Our addin can't be the only code affected by this, right? There must be a reason why Inventor ships its own copy of this DLL - some AutoDesk functionality or addin must need it (no idea what though), and that functionality would also be broken by this mismatch in the same way that our addin is.

 

How should we procede?

0 Likes
485 Views
3 Replies
Replies (3)
Message 2 of 4

M.Zirk
Advocate
Advocate

Hello,

 

ususally you add your desired newtonsoft.dll to your vb. project by NuGet Manager and copy it during compilation into your addin output directory.

Mark in VB. project for your appilication settings "generate binding redirections automatically".

 

For me inventor should use it own newtonsoft.dll and your addin should also use its own newtonsoft.dll.

Im my addin i use newtonsoft.dll version 13 and Inventor uses version 12. And there are no problems.

 

I'm not sure if this work fine also with Inventor 2022.

 

Maybe that helps.

 

Manfred

 

0 Likes
Message 3 of 4

scharrerVHKNR
Explorer
Explorer

The addin is not a separate application, it's a DLL that implements the `Inventor.ApplicationAddInServer` COM interface, as shown here:
https://help.autodesk.com/view/INVNTOR/2022/ENU/?guid=GUID-52422162-1784-4E8F-B495-CDB7BE9987AB

 

Inventor loads the addin into the Inventor process, and thus the binding redirections defined in `Inventor.exe.config` apply.

 

I don't think it's possible for an in-process DLL to have its own binding redirections, or am I mistaken?

0 Likes
Message 4 of 4

M.Zirk
Advocate
Advocate

Hello ,

my addin is also an dll, executed in Inventor.

 

Manfred

 

 

0 Likes