I have an asp.net core 2.0 application that runs on full .net framework 4.6.1. It works fine locally but when I deploy it to Azure I receive the following error:
FileLoadException: Could not load file or assembly 'System.Runtime, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
In Debug/Release folder I have System.Runtime 4.1.2.0 but somehow it works.
In "classic" .NET framework I used to add assembly redirect to app.config but here I don't have web.config. Any idea how to fix that?
What worked for me was:
Simply, empty the bin folder in your project and rebuild. I had to manually delete the contents via windows explorer as 'clean' left files kicking around.
Job done.
This can happen if you create an ASP.NET Core 2.0 Web Application that targets the [.NET Core]
platform, deploy to Azure (or deploy locally), and then change it to target the [.NET Framework]
instead.
e.g. if you change
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>
to
<PropertyGroup>
<TargetFramework>net461</TargetFramework>
</PropertyGroup>
but if you do not delete the existing files from Azure before redeploying you will get this error.
It can also happen in the following scenario:
First create a .NET Core project with Visual Studio 2017 with:
File -> New Project -> Visual C# > Web > Asp.NET Core Application`
Choose the [.NET Core]
Platform on the Second Screen.
Then create a new Project with :
File -> New Project -> Visual C# > Web > Asp.NET Core Application`
Choose the .NET Framework setting on the Second Screen.
Redeploy without deleting the existing files from Azure will cause this error.
Hope that helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With