So I've built a Com Interfaced DLL. I've fully tested it using Nunit. I had an issue with Newtonsoft.Json not found and resolved by including it in the Class library project. Now As I said the project is a COM interfaced DLL. When I call the DLL from my VBA development system I get the error, I've not yet tested outside the IDE for this VBA development system, makes no sense to do so.

So what is this DLL for? It is an interface to vendor WEBAPIs. It also serves as a TCP database access tool. So included, via NUGET package, in the DLL is WatsonTCP which relies on Newtonsoft.Json. That is the point where the failure occurs. It is using .Netframework 4.7.2.

I have copied the newtonsoft.Json.DLL to the VBA project folder, the VBA IDE exe folder, System folder, syswow64. none seem to resolve the issue. The dll is executing from the bin folder under the Class project as expected.

Any further suggestions? I've been digging on the web and so far the above attempts are what is suggested on the net. Or perhaps I've not entered the correct search words 8).

2

Best Answer


You have to install the Nuget package Newtonsoft.Json, therefore when you build the project you will be able to use it.Just remember to copy the JSON DLL to wherever the executable that uses you other DLL is.

After several attempts to resolve, thanks to all who posted here and to those that posted to the links offered here, I decided to take a blunt approach. First I removed all project references to Newtonsoft.Json via installed NUGET packages, had issue with WatsonTCP as it is dependent on Newtonsoft.Json, that had to go too.

As I had downloaded the WatsonTCP sources previously when obtaining the samples of how to use it I decided to include the WatsonTCP project into my solution. I added the project as a reference in my project, updated the NUGET newtonsoft.Json to current version and it now works as expected from the VBA app.

Note: I did confirm that all dlls were in the Bin folder of the COM module I was calling before taking this path as well as confirming the bin folder was clean. Here is what the solution looks like now via VS2022.

VS2022 snapshot of solution.