Getting exception System.Web.Http in VS2013 using breeze? - asp.net

I am trying to create the HotTowel Sample application from Jhon Papa using Breeze and AngularJS. I have installed all the required packages and before installing Breeze.WebApi package everything works fine but after i installed this package then i am getting this below exception on WebApiRoute configuration method.
<ExceptionMessage>
Could not load file or assembly 'System.Web.Http, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's
manifest definition does not match the assembly reference. (Exception from HRESULT:
0x80131040)
I have referenced the System.Web.Http dll to project but with latest 5.0.0 version.

You can try to do a binding redirect to point to new assemblies and see if it works.
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Http" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>

This was likely a result of trying to use the new Microsoft WebApi2 nuget packages in VS 2013. Previously Breeze did not support these.
As of now, Breeze 1.4.5 has support for Microsoft's ASP.NET WebApi 2 and Entity Framework 6. Please see http://www.breezejs.com/documentation/download.

Related

Stuck in Entity Framework due to Castle.Core

I've followed the tutorial but it seems a bit outdated (ref. https://aspnetboilerplate.com/Pages/Documents/Articles/Introduction-With-AspNet-Core-And-Entity-Framework-Core-Part-1/index.html).
I build the program and then I do an Update-Database, but I get stuck on following error:
Could not load file or assembly 'Castle.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
First, I checked if I used the most recent version of .NET Core and then updated to latest (dotnet-sdk-2.1.202-win-x64.exe). Afterwards, I checked NuGet and I've got the most recent versions of Castle.Core, Castle.Facilities.Logging and Castle.Windsor.
I then tried following changes in the Entity Framework project, App.config file:
I removed bindingRedirect from Castle.Core, making it:
<dependentAssembly>
<assemblyIdentity name="Castle.Core" publicKeyToken="407dd0808d44fbdc" culture="neutral" />
</dependentAssembly>
In NuGet, I've updated ABP and ABP Entity Framework from 3.8.1 to 3.8.2.
Reloaded the DLLs for Castle.
When I ALSO removed the bindingRedirect from Castle.Core in the Core project, it started to work.
<dependentAssembly>
<assemblyIdentity name="Castle.Core" publicKeyToken="407dd0808d44fbdc" culture="neutral" />
</dependentAssembly>

ExcelDataReader 3.4 - System.IO.FileLoadException

I'm using ExcelDataReader 3.4 and it work fine on my developer PC, but when used on production PC, I've got this error
System.IO.FileLoadException: Could not load file or assembly 'System.IO.Compression, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT : 0x80131040)
In my project I have System.IO.Compression copied local.
I'm using .NET 4.5, Visual Studio 2017
I found the issue. In the App.Config of my WPF application there was those line
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.IO.Compression" publicKeyToken="b77a5c561934e089" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-4.2.0.0" newVersion="4.2.0.0"/>
</dependentAssembly>
</assemblyBinding>
I changed the version for 4.0.0.0 and now its working.

Project stops working after installing signalr

After I install signalr to my project and try to run the project I have this error message
Error message:
Could not load file or assembly 'Newtonsoft.Json, Version=4.5.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)
How can I solve this problem.
After I search in the Internet for any solution, I didn't find any solution.
The only way that solve the problem is to install old version of signalr.
I install version 2.1.0. This version doesn't change the version of Newtonsoft.Json.
Thanks for all replies.
reinstall Newtonsoft.Json dll again, SignalR installs an old version of Newtonsoft.Json dll, and make sure that your web config file references the newer verion.
I think this is the error you meant (I remember encountering this as well but that was quite some time ago).
Try adding the following
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.1.0.0" />
</dependentAssembly>
under
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
....
in your hub's web.config file and try

"The located assembly's manifest definition does not match the assembly reference" on nuget package

So I was persistently getting this error on the System.Web.Optimization package
Could not load file or assembly 'System.Web.Optimization' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
I finally found the solution after much trying.
The key was in the Assembly load trace.
LOG: Redirect found in application configuration file: 1.0.0.0 redirected to 1.1.0.0.
Here are the steps I took to resolve the issue. It might be possible to skip some of these but this worked for me:
Uninstall the nuget package
Microsoft.AspNet.WebOptimization.WebForms
Delete bin folder
open web.config and locate the redirection.
It will look something like this:
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Optimization" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.1.0.0" newVersion="1.1.0.0" />
</dependentAssembly>
</assemblyBinding>
I removed the entire assemblyBinding section from the web.config.
Finally re-install the Microsoft.AspNet.WebOptimization.WebForms
package and rebuild.
I don't know where this section came from in the web.config but having removed it everything seems to be working once again.

Assembly Conflict in Newtonsoft.Json

We are getting an assembly conflict after we updated Newtonsoft.Json. I am having trouble understanding where the specific version that is referenced in the error is coming from. There is nothing in the web.config that points to a specific version.
System.IO.FileLoadException: Could not load file or assembly
'Newtonsoft.Json, Version=3.5.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)
Would GAC-ing the two versions of the assembly work to solve the issue?
As #jammykam commented in marto's answer you can redirect the assembly. I have done this in the past with Newtonsoft and Sitecore without a problem. You can take a look at my Sitecore Content as Service code where I have it working.
You are specifically interested in these lines in the web.config file:
https://github.com/HedgehogDevelopment/sitecore-content-service/blob/master/Sitecore/Web/Web.config#L3499
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.8.0" newVersion="4.5.0.0" />
</dependentAssembly>
GACing them might work but it will create a maintenance nightmare. Don't do it!
I think you have 2 options:
Use the version that came with Sitecore which will depend on which version of Sitecore you are running.
Leave the one sitecore version untouched and use ilmerge to combine the Newtonsoft.Json version you need with your own assembly.
I would recommend 1 if you don't need any of the most recent features of the library like (dynamics... etc)

Resources