0

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).

Larry
  • 177
  • 1
  • 1
  • 10
  • Thank you for the suggestion, I'll read and try it out. Thanks. – Larry Feb 21 '22 at 15:55
  • Are you keeping all the DLL files together? Or did you move the main DLL away from it's dependencies? Everything that comes out when you compile your C# project needs to be in the same folder together at runtime. – HackSlash Feb 21 '22 at 17:27
  • @hackslash, Yes the entire project and support dlls are in the same folder. I've even checked the main DLL.config file and it has the dependency as follows: – Larry Feb 22 '22 at 15:11

2 Answers2

0

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.

Raskayu
  • 735
  • 7
  • 20
  • Thanks, that is done, again the DLL has been fully tested/vetted through Nunit tests. The failure is when calling the DLL from the VBA application. – Larry Feb 21 '22 at 15:59
  • You need to copy the JSON dll to the executable folder – Raskayu Feb 22 '22 at 16:07
  • 1
    Thanks, yes that was the first round of testing. I put the DLL in all the places suggested in several postings. After much review I just added the WatsonTcp cloned NUGET sources ensuring the NUGet package for newtonsoft.Json is set to the latest to my DLL project. The problem was resolved. – Larry Feb 22 '22 at 19:44
0

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.

Larry
  • 177
  • 1
  • 1
  • 10
  • This may have been a NUGET dependency issue on Newtonsoft.Json NUGET declared by WatsonTCP, rather than fight the NUGET for WatsonTCP I used the sources and set the newtonsoft.Json version. – Larry Feb 23 '22 at 14:46