Hello,
I'm developing a VSIX that contains a VS Package, project templates, snippets, etc. for my Constellation's SDK (www.myconstellation.io).
The latest version of the Constellation's client library reference JSON.NET (Newtonsoft.Json) version 8.0 and this library is used in my VS Package for some work.
When I call a method of my library from a DialogWindow of my VSPackage, I have a RuntimeBinderInternalCompilerException (an unexpected exception occurred while binding a dynamic operation) when I try the cast a dynamic object that contains JSON in JArray (or JObject).
The same method called from a standalone WPF application works perfectly!
After investigation, I realized by opening the Module window (Debug>Windows>Modules) that Visual Studio has already loaded the Newtonsoft.Json assembly :
In "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\PrivateAssemblies", I have the file "Newtonsoft.Json.dll" version 6.0, and in my VS Package, the version 8.0 of Newtonsoft.Json used by my Constellation library.
That why I have an exception when I try to do something with the dynamic object of JSON.net !
So how can I do to ship my SDK that uses a library itself based on Json.net 8.0 (and I can't downgrade my library to Json.net v6.0) ???
Currently I found a workaround by editing the "devenv.exe.config" to change the assembly bindings :
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-8.0.0.0" newVersion="8.0.0.0" />
<codeBase version="8.0.0.0" href="C:\xxxxxxxxx\Newtonsoft.Json.dll"/>
</dependentAssembly>
This works fine, but I'm not sure that this is very clean to edit the VS configuration file from my SDK installer ?
I can perhaps try to create an AppDomain to do my work but it will be quite complicated because there are many thing to do and in interaction with a lot of VS services & API.
Thank you for your answer, and sorry for my poor english ;)