In Visual Studio 2015, I have Project A (Web Api Application) and Project B (MVC Application) in the same solution.
I can debug application A and application B separately.
But, When application B calls rest api from A, I receive dll dependency error from application A.
"Could not load file or assembly 'Newtonsoft.Json' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference".
When I clean build project A, at the first time call is successful, however subsequent calls receive same error.
How can I fix this?
(I use IIS 7.5)
To solve this, please mark sure that your two projects used the same Newtonsoft.Json version.
You can run the following command:
update-package Newtonsoft.Json -reinstall
Please also view your web.config, maybe you could remove the old version like:
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" /> </dependentAssembly>
Generally if we want to ensure all Newtonsoft.Json packages are the same version, we also can specify the version:
update-package Newtonsoft.Json -version 6.0.0 -reinstall
Reference:
Could not load file or assembly 'Newtonsoft.Json, Version=7.0.0.0
http://blog.myget.org/post/2014/11/27/Could-not-load-file-or-assembly-NuGet-Assembly-Redirects.aspx
Related
I am setting up my first Windows IoT Core background application that is running on a Raspberry Pi, but I am running into a problem with conflicting assembly versions and I have been unable to resolve them.
Specifically, I am getting an error message that states:
No way to resolve conflict between "System.Data.Common, Version=4.2.1.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" and "System.Data.Common,
Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a". Choosing
"System.Data.Common, Version=4.2.1.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a" arbitrarily.
Upon closer inspection, there are two versions of the System.Data.Common.dll that my application is referencing.
The first is coming from the installed package Microsoft.NETCore.UniversalWindowsPlatform (v 6.2.8). The assembly version of System.Data.Common here is 4.2.1.0 (which is the version I want to use):
Assembly System.Data.Common version 4.2.1.0
C:\Users\mikel\.nuget\packages\Microsoft.NETCore.UniversalWindowsPlatform\6.2.8\ref\uap10.0.15138\System.Data.Common.dll
The second is apparently being included as a dependency with the .netstandard:
Assembly System.Data.Common version 4.1.0.0
C:\Users\mikel\.nuget\packages\System.Data.Common\4.3.0\ref\netstandard1.2\System.Data.Common.dll
I am having a little harder time pinpointing exactly what is forcing NuGet to download and install the second package. Perhaps one of my other packages that I need is referencing it as a dependency (not sure).
Either way, I would like to setup assembly binding remapping so that any attempt to reference 4.1.0.0 will redirect and use 4.2.1.0.
When I do a build of my project, I get this warning:
1> Consider app.config remapping of assembly "System.Data.Common, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a" from Version "4.1.0.0"
[C:\Users\mikel\.nuget\packages\System.Data.Common\4.3.0\ref\netstandard1.2\System.Data.Common.dll]
to Version "4.2.1.0"
[C:\Users\mikel\.nuget\packages\Microsoft.NETCore.UniversalWindowsPlatform\6.2.8\ref\uap10.0.15138\System.Data.Common.dll]
to solve conflict and get rid of warning.
However from what I have read, Universal Windows Projects do not support the use of app.config files. At any rate though, I added an app.config file to the root of my project, set the build action to Embedded Resource, selected Copy Always and put this in the file (to no affect):
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Data.Common" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="4.1.0.0" newVersion="4.2.1.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
I have also tried setting the NuGet project management format to PackageReference and added <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> to each PropertyGroup in my .csproj file. This did not have any impact.
My Universal Windows project targets are as follows:
Target version: Windows 10 Fall Creators Update (10.0; Build 16299)
Minimum Version: Windows 10 Fall Creators Update (10.0; Build 16299)
I should also state that I want to use the 4.2.1.0 version of the assembly, as 4.1.0.0 is missing a few things I need to implement the wrapper I am using around SQLite. My preference is to not have to re-write those wrappers.
At this point I am very confused as to how to resolve this conflict. How do I enable binding redirects to resolve this error?
Any help would be greatly appreciated.
Getting started with creating NuGet packages for various common libraries, that were up to now typically added as a project to a solution.
Using TFS 2017 to build and deploy the NuGet packages to the Package Manager built into TFS 2017.
I have an issue with dependencies and don't fully understand how to resolve it. It's also a little complicated to detail; so here goes.
I have built a class library that has a NuGet package installed - The package is SharpRaven 2.2.0
SharpRaven has a dependency on NewtonSoft.Json >= 6.0.8
This results in Newtonsoft.Json being added to my class library. By default NewtonSoft.Json 6.0.8 is installed.
I then package up my class library as a NuGet package - Called it TestNuGet
TFS is building the nuget by using the .csproj file and not the nuspec
When I use this new package in projects I see there are dependencies for SharpRaven and Newtonsoft (if neither of those are currently installed in the project).
My problem starts with Newtonsoft.Json.
Take the following projects:
Solution A and B
- Already has Newtonsoft 9.0.1.
- Install TestNuGet, so SharpRaven is also added
- Project is fine, no errors when using TestNuGet
Solution C
- Already has Newtonsoft 9.0.1.
- Install TestNuGet, so SharpRaven is also added
- Errors when calling TestNuGet; error below:
Solution C
- Remove Newtonsoft 9.0.1
- Install TestNuGet, SharpRaven and Newtonsoft 6.0.8 installed
- Project is fine. No errors
- Update Newtonsoft
- Get Errors again as before
If i update NewtonSoft to 9.0.1 in TestNuget and rebuild it I get exactly the same issues above.
There are no projects within Solution C that are referencing anything other than 9.0.1.
It seems to me that when adding a NuGet package NuGet looks at all of the packages within and uses those dependencies, ignoring what is already added to the TestNuget.
So the question, i think - Is there a way to instruct nuget to use the newtonsoft version i added to TestNuget and to not try and meet the dependency sharpraven is calling for? Something to add to the Packages.config perhaps?
Would I be better using a nuspec file? is there more that can be set in this to control how the package is built?
Or is there something I'm missing in my usage of these packages.
Error being thrown when trying to use the package is:
Could not load file or assembly 'Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Binding Redirect from the web.config of the solution that will not run looks as this:
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0" />
</dependentAssembly>
I also tried adjusting the redirect to encapsulate 9.0.1
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-9.0.1.0" newVersion="9.0.1.0" />
</dependentAssembly>
The issue here is that an assembly has a reference to a version 6 of NewtonSoft.Json which is not found at runtime since only a higher version is present.
This is usually worked around with binding redirects. NuGet should automatically generate the necessary binding redirects into runnable (exe, web apps) projects using packages.config when installing packages.
For PackageReference based projects it is sometimes (test projects, plugin-library, …) required to also tell msbuild to automatically generate the needed binding redirects based on the resolved assemblies. This can be done by adding this to the csproj file:
<PropertyGroup>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
</PropertyGroup>
However this does not protect against actual breaking changes that could have occurred in new major versions of a library.
Also note that these binding redirects may be overwritten by the binding redirects of other applications re-using the built assembly (parent projects, plugin-system etc).
I am running Visual Studio 2010 Ultimate. I have installed the Intuiut SDK v12.0 to its default location. I copied the file "IntuitWizardQBFC.zip" and pated it into the templates folder for visual studio. The icon for the quick books template is on the interview screen but when I click on it I get an error message. It states "Could not load file or assembly 'Interop QBFC10, Version=11.0.0.132, Culture=neutral, PublicKeyToken=31d8aec64e18259' or one of it's dependencies. The system cannot find the specified file" I saw a similar post regaurding an existing application. I cannot open the template to create the first application. My machine is Windows 7 64 bit. When I write programs for class I set the target to x86 so If I can test them on older computers. This setting is usually set after the solution is created when the new project is started. Please help I am currently using access to get data from my QB data base and want to do something diffrent.
The template wizard assembly IntuitWizardQBFC has a reference to version 11.0.0.132 of Interop.QBFC10, which is not present on your system. Go to C:\Windows\Assembly, look for Interop.QBFC10, and see what it says in the Version column. In my case, it says 11.0.0.29.
You can force Visual Studio to use version 11.0.0.29 instead of 11.0.0.132 by redirecting assembly versions. Edit devenv.exe.config, and just before the closing </assemblyBinding> tag, add this:
<dependentAssembly>
<assemblyIdentity name="Interop.QBFC10" publicKeyToken="31d8aec643e18259" culture="neutral"/>
<bindingRedirect oldVersion="11.0.0.132" newVersion="11.0.0.29"/>
</dependentAssembly>
Close Visual Studio if it was open; start it up, and create a new project using the template. Instead of showing the error message, it should launch the wizard.
Try installing QBFC10 and then try the template. It is possible I forgot to update the template when SDK 12 was built.
You can download QBFC10 from the same location you got the SDK.
William
I just downloaded the QuickBooks Desktop SDK v13 today and it still has this issue with the VS.NET Project Wizard.
Following up on Adam C's post above, the complete path to this node in the devenv.exe.config is as follows:
<?xml version ="1.0"?>
<configuration>
...
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
...
<dependentAssembly>
<assemblyIdentity name="Interop.QBFC10" publicKeyToken="31d8aec643e18259" culture="neutral"/>
<bindingRedirect oldVersion="11.0.0.132" newVersion="11.0.0.29"/>
</dependentAssembly>
...
</assemblyBinding>
</runtime>
...
</configuration>
I've updated my project with new DLLs. I've updated the Assembly version and the File version of these DLLs to new (higher) values. I've rebuilt the setup project and increased the version of the setup and said yes to changing the Product code. I've added an assembly binding redirect to the app.config:
<dependentAssembly>
<assemblyIdentity name="LibVlcWrapper" publicKeyToken="F2C6CD8B56B49D4C" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-2.0.0.9" newVersion="2.0.1.0"/>
</dependentAssembly>
.. Yet still when people are installing the update the new DLL isn't being copied over the old DLL. Anyone got any idea why? I keep getting error reports like:
Could not load file or assembly 'Implementation, Version=2.0.1.0, Culture=neutral, PublicKeyToken=be745ff6cbf41b62' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
The problem was that'd i'd already updated the DLL to the same version - doh! Thanks Alexey for pointing out the debug generator.
I am using the 1.0 RTM of Fluent Nhibernate, with a 3.0 build of NHibernate. In order to do this, I need to add the following to my .config file:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="NHibernate" culture="neutral" publicKeyToken="aa95f207798dfdb4"/>
<bindingRedirect oldVersion="2.1.0.4000" newVersion="3.0.0.1001"/>
</dependentAssembly>
</assemblyBinding>
This works great when running integration tests with the TestDriven.net plugin, but fails in the NUnit gui or console runner with the following error:
System.IO.FileLoadException : Could not load file or assembly 'NHibernate, Version=2.1.0.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
How do I get NUnit to respect my bindingRedirect and run my integration tests successfully?
I've had similar issues when running nunit on a CI Server (bamboo, to be specific). The way I understand it is that if nunit is running in its own process space (like you're just just running it from command line), then it can correctly read the .dll.config assembly binding redirects. However, if your CI Server is running nunit within the CI Server's process space, then it tries to get the config from the parent process. To ensure that nunit gets run in its own process space, add the command line option /process:multiple. At least, that is what worked for me so that nunit would properly find the redirect bindings.
TL;DR: use the command line option /process:multiple
The key is putting it in the correct .config file. See Does redirecting assembly binding work for unit testing with a test runner?.
Another approach would be compiling fluent-nhibernate against NHibernate 3.0. If it has compilation errors, ask the dev team and/or fork the source and make it compile.