ExcelDataReader 3.4 - System.IO.FileLoadException - exceldatareader

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.

Related

Microsoft.SqlServer.Types.dll: The located assembly's manifest definition does not match the assembly reference

The software I am debugging is a console application, using .net Framework 4.7.2.
In visual studio I have installed the Microsoft.SqlServer.Types.dll v14.0.1016.290 via Nuget.
Error Message:
Error: Could not load file or assembly 'Microsoft.SqlServer.Types, Version=10.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
In packages.config I have added this line:
<packages>
<package id="Microsoft.SqlServer.Types" version="14.0.1016.290" targetFramework="net472" />
</packages>
In app.config I have deleted this line, and it has added itself back again:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Microsoft.SqlServer.Types" publicKeyToken="89845dcd8080cc91" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-14.0.0.0" newVersion="14.0.0.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
I also have msvcr120.dll and SqlServerSpatial140.dll in the base directory.
I cannot figure out why the software is trying to load v10 of sqlServer.Types?
What am I missing?
Thank you for your help.

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>

Could not load file or assembly 'EntityFramework' after downgrading from 4.5 to 4.0 with EF5

I recently developed a .net 4.5 library using Entity Framework 5. Everything worked fine until I've been told I had to downgrade to .net 4.0 in order to remain compatible with Windows 2003.
I uninstall EF 5 using the Package Manager Console and had the successfull message, then this one:
Failed to generate binding redirects for 'MyProjectName'. An item with the same key has already been added.
The same message appears after downgrading and installation of Entity Framework.
Everything compile. But on execution I've this exception:
The type initializer for 'System.Data.Entity.Internal.AppConfig' threw an exception.
Could not load file or assembly 'EntityFramework, Version=5.0.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)":"EntityFramework, Version=5.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089"
In the Web.Config (and App.Config of the libraries) I have those lines:
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
...
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="EntityFramework" publicKeyToken="b77a5c561934e089"
culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
Any help would be appreciated.
I finally solved the problem thanks to another topic: could-not-load-file-or-assembly-entityframework-after-downgrading-ef-5-0-0-0
Despite I installed EF 5 package with the Package Manager Console. The actual version of Entity Framework for .Net 4.0 is version 4.4. I've changed the value in config files and it worked!
<section name="entityFramework"
type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework,
Version=4.4.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
...
<dependentAssembly>
<assemblyIdentity name="EntityFramework" publicKeyToken="b77a5c561934e089"
culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-4.4.0.0" newVersion="4.4.0.0"/>
</dependentAssembly>
Use Nuget to uninstall EF then add it again, Clean and rebuild your project.

Getting exception System.Web.Http in VS2013 using breeze?

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.

Could not load file or assembly 'System.Web.Mvc, Version=3.0.0.0, Elmah.MVC issue

Locally - my MVC 4, asp.net, c# app runs fine on IIS 8 / Windows 8.
When deployed to Windows Server 2008, I get this error:
Could not load file or assembly 'System.Web.Mvc, Version=3.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)
and
[FileLoadException: Could not load file or assembly 'System.Web.Mvc, Version=3.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)]
Elmah.Mvc.Bootstrap.Initialize() +0
[InvalidOperationException: The pre-application start initialization method Initialize on type Elmah.Mvc.Bootstrap threw an exception with the following error message: Could not load file or assembly 'System.Web.Mvc, Version=3.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).]
System.Web.Compilation.BuildManager.InvokePreStartInitMethodsCore(ICollection`1 methods, Func`1 setHostingEnvironmentCultures) +12881963
System.Web.Compilation.BuildManager.InvokePreStartInitMethods(ICollection`1 methods) +12881672
System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath) +240
System.Web.Compilation.BuildManager.ExecutePreAppStart() +152
System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +1151
[HttpException (0x80004005): The pre-application start initialization method Initialize on type Elmah.Mvc.Bootstrap threw an exception with the following error message: Could not load file or assembly 'System.Web.Mvc, Version=3.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).]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +12881108
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +159
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +12722297
This happens if I select 'Only files needed to run this application' from the 'Items to deploy' drop down in project properties/package/publish web.
If I select 'all files in this project' it works fine.
I guess Elmah is reliant on an older version of MVC or something - how can I fix this without having to upload all the files?
Whats the best way to problem solve situations like this?
Thanks.
I had this exact same issue using MVC4 with Ninject built for .Net 4.5
To fix this i had to add a binding redirect to my Web.config file:
(at the end of the file, just before the </configuration> tag)
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35"/>
<bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35"/>
<bindingRedirect oldVersion="1.0.0.0-4.0.0.0" newVersion="4.0.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35"/>
<bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages.Razor" publicKeyToken="31bf3856ad364e35"/>
<bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
This forces the web server to use System.Web.Mvc 4.0.0.0 instead of an older version.
<dependentAssembly>
***<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-5.2.7.0"*** newVersion="5.2.7.0" />
</dependentAssembly>
Check correct versions are there
To install System.Web.Mvc 3.0.0.0 version
1) Install windows web platform installer
2) Open Windows web platform installer from start menu
3) Go to Products tab
4) Search for MVC
5) Install MVC 3
There are some procedures using to fix the issue and if the binding redirect in web.config does not solve the problem, you can try the following steps to fix it:
1) In Visual Studio Solution Explorer tree right-click References under your web project and select Manage NuGet Packages.
2) Go to Browse tab and select nuget.org as Package source.
3) Search and install the following packages: Ninject, Ninject.Web.Common and Ninject.MVC5.
It is also better to update the packages particularly Microsoft ASP.NET MVC on Updates tab of Manage NuGet Packages.
In the error page I had this:
LOG: Redirection detected in the application configuration file: 5.1.0.0 was redirected to 5.2.3.0.
So I had to change this line in the web.config to the 5.1.0.0 version and it worked!
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.1.0.0" />
<!--<bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" /> Older line -->
</dependentAssembly>
I think this is due to a version problem when I downloaded the code from TFS
Hope this helps
Add below code in web.config:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.1" />
</dependentAssembly>
</assemblyBinding>

Resources