I have a COM interface setup between my C# class library and a native executable. The native exe makes a call into the managed module, which should return a string (which is marshalled to a BSTR c++ side). During this call, the following line is hit:
HttpResponseMessage response = await client.PostAsJsonAsync("", data).ConfigureAwait(false);
When it hits this, it bails. If I remove the line, the code continues. As the result returns a BSTR, upon inspecting the BSTR it reads:
Could not load file or assembly 'Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The system cannot find the file specified.
I found that this PostAsJsonAsync comes from System.Net.Http.Formatting
However the error message says Newtonsoft.Json, implying there is some kind of conflict? Yes?
Maybe related: HttpClient PostAsJsonAsync incompatible with Newtonsoft.Json
So I want to understand what I actually happening here. When the native project loads the managed library for COM, does it load the wrong assembly causing a naming conflict with PostAsJsonAsync?? My best guess. Secondly, what is the correct solution?
Thanks,
Edit: Note I am actually using Newton.Json for json serial/deserialization