In the course of trying to help the EF Core team verify that a bug I'd run across was fixed in v1.1, I updated a functioning solution to both EF Core 1.1 and AspNet Core 1.1.
And I really, really, wish I hadn't.
First off, my previously-functioning MVC6 site stopped working, complaining about a version mismatch on Microsoft.Logging.Abstractions (I think it involved not being able to find v1.0.0 of that assembly).
So I figured I'd just revert everything back to where it was before I did the test for the EF Core team. That should fix everything, right?
Wrong.
Now I'm getting the following:
System.IO.FileLoadException was unhandled
Message: An unhandled exception of type 'System.IO.FileLoadException' occurred in Unknown Module.
Additional information: Could not load file or assembly 'Microsoft.AspNetCore.Hosting, Version=1.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Here's the project.json file for the MVC6 app:
{
"userSecretsId": "aspnet-ConnellCampaigns-ddb1a50a-eba1-4870-91d4-4d26457f64ce",
"dependencies": {
"AutoMapper": "5.1.1",
"BundlerMinifier.Core": "2.2.296",
"ConnellData": "1.0.0-*",
"ConnellDataCore": "1.0.0-*",
"Microsoft.AspNetCore.Authentication.Cookies": "1.0.0",
"Microsoft.AspNetCore.Diagnostics": "1.0.0",
"Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore": "1.0.0",
"Microsoft.AspNetCore.Identity.EntityFrameworkCore": "1.0.0",
"Microsoft.AspNetCore.Mvc": "1.0.1",
"Microsoft.AspNetCore.Razor.Tools": {
"version": "1.0.0-preview2-final",
"type": "build"
},
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.1",
"Microsoft.AspNetCore.StaticFiles": "1.0.0",
"Microsoft.Azure.WebJobs": "1.1.2",
"Microsoft.EntityFrameworkCore.SqlServer": "1.0.1",
"Microsoft.EntityFrameworkCore.SqlServer.Design": "1.0.1",
"Microsoft.EntityFrameworkCore.Tools": {
"version": "1.0.0-preview2-final",
"type": "build"
},
"Microsoft.Extensions.Caching.Memory": "1.0.0",
"Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
"Microsoft.Extensions.Configuration.Json": "1.0.0",
"Microsoft.Extensions.Configuration.UserSecrets": "1.0.0",
"Microsoft.Extensions.Logging": "1.0.0",
"Microsoft.Extensions.Logging.Console": "1.0.0",
"Microsoft.Extensions.Logging.Debug": "1.0.0",
"Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0",
"Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0",
"Microsoft.VisualStudio.Web.CodeGeneration.Tools": {
"version": "1.0.0-preview2-final",
"type": "build"
},
"Microsoft.VisualStudio.Web.CodeGenerators.Mvc": {
"version": "1.0.0-preview2-final",
"type": "build"
},
"Microsoft.WindowsAzure.ConfigurationManager": "3.2.3",
"Serilog": "2.3.0",
"Serilog.Extensions.Logging": "1.2.0",
"Serilog.Sinks.Literate": "2.0.0",
"Serilog.Sinks.RollingFile": "3.2.0",
"UploadFramework": "1.0.0-*",
"WindowsAzure.Storage": "7.2.1"
},
"tools": {
"BundlerMinifier.Core": "2.0.238",
"Microsoft.AspNetCore.Razor.Tools": "1.0.0-preview2-final",
"Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final",
"Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final",
"Microsoft.Extensions.SecretManager.Tools": "1.0.0-preview2-final",
"Microsoft.VisualStudio.Web.CodeGeneration.Tools": {
"version": "1.0.0-preview2-final",
"imports": [
"portable-net45+win8"
]
}
},
"frameworks": {
"net46": {
"frameworkAssemblies": {
"System.IO.Compression": "4.0.0.0"
},
"dependencies": {
}
}
},
"buildOptions": {
"emitEntryPoint": true,
"preserveCompilationContext": true
},
"runtimeOptions": {
"configProperties": {
"System.GC.Server": true
}
},
"publishOptions": {
"include": [
"wwwroot",
"Views",
"Areas/**/Views",
"appsettings.json",
"web.config"
]
},
"scripts": {
"prepublish": [ "bower install", "dotnet bundle" ],
"postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
}
}
I'd appreciate help in getting me back to my paying work :). Also advice on how to diagnose this kind of problem in the future (other than never, ever, ever offering to test things :)).
In the bin/<configuration>/<framework>/
folder is a *.deps.json
which shows the dependencies your project got from restoring and all the references it has. You can navigate that file to see where the 1.1.0 reference to hosting is coming from.
You might have stray binaries \ app.config in your bin directory. Does wiping the bin directory and rebuilding work?
Thanx, Brennan and Prana, for the quick replies. Brennan, I didn't check out your suggestion because Prana's approach solved the problem. But I'll definitely keep it in mind for the future.
Clearing the bin directory did fix the problem. The app's config file had a lot of references to later versions of assemblies that it shouldn't have contained after I regressed the app. But what confuses me is that I did a "Clean Solution" and Rebuild before asking for help, because I've seen similar problems caused by cruft. I thought "Clean Solution" wiped out the contents of the bin directory...but it didn't in this case (I checked). I had to delete the directory contents manually. Apparently, the behavior of Clean changed somewhere along the way.
I think this is similar to #1824, but for me wiping the bin folder or deleting nuget cache didn't solve the issue.
Nothing works for me. I removed entire project, published again, but still receive the error: Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.AspNetCore.Hosting, Version=1.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
Running from debug mode (dotnet run) works fine. But running production (dotnet /var/www/myapp/MyApp.dll) does not.
Solved. It was missing "Microsoft.AspNetCore.Server.Kestrel": "1.1.0", in my project.json file.
In 1.0.1 it was optional, but now it麓s required.
I have the same error when publishing to azure web apps,
Unhandled Exception: System.IO.FileLoadException: Could not load file or assembly 'Microsoft.AspNetCore.Hosting, Version=1.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Is using "Microsoft.AspNetCore.Server.Kestrel": "1.1.0" package a good solution for asp.net core 1.0?
here's my project.json:
{
"buildOptions": {
"emitEntryPoint": true,
"preserveCompilationContext": true
},
"dependencies": {
"Microsoft.ApplicationInsights.AspNetCore": "1.0.2",
"Microsoft.AspNetCore.Authentication.Cookies": "1.0.0",
"Microsoft.AspNetCore.Authentication.OpenIdConnect": "1.0.0",
"Microsoft.AspNetCore.Authorization": "1.0.0",
"Microsoft.AspNetCore.Diagnostics": "1.0.0",
"Microsoft.AspNetCore.Mvc": "1.0.1",
"Microsoft.AspNetCore.Mvc.Core": "1.0.1",
"Microsoft.AspNetCore.Mvc.TagHelpers": "1.0.1",
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.1",
"Microsoft.AspNetCore.StaticFiles": "1.0.0",
"Microsoft.EntityFrameworkCore.Design": "1.0.1",
"Microsoft.EntityFrameworkCore.SqlServer": "1.0.1",
"Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview3-final",
"Microsoft.Extensions.Configuration.Binder": "1.1.0",
"Microsoft.Extensions.Configuration.EnvironmentVariables": "1.1.0",
"Microsoft.Extensions.Configuration.FileExtensions": "1.1.0",
"Microsoft.Extensions.Configuration.Json": "1.0.0",
"Microsoft.Extensions.Logging": "1.0.0",
"Microsoft.Extensions.Logging.Console": "1.0.0",
"Microsoft.Extensions.Logging.Debug": "1.0.0",
"Microsoft.IdentityModel.Protocols.OpenIdConnect": "2.1.0",
"Microsoft.NETCore.App": "1.0.1",
"Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.1.0",
"Newtonsoft.Json": "9.0.2-beta1",
"WindowsAzure.Storage": "7.2.1"
},
"frameworks": {
"netcoreapp1.0": {
"imports": [
"dotnet5.6",
"portable-net45+win8"
]
}
},
"publishOptions": {
"include": [
"wwwroot",
"Views",
"web.config",
"appsettings.json",
"appsettings.*.json",
"LICENSE.txt"
]
},
"runtimeOptions": {
"gcServer": true
},
"runtimes": {
"win10-x64": {},
"win7-x64": {}
},
"scripts": {
//"prepublish": [ "npm install", "npm recompileapp" ],
"postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
},
"tools": {
"Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final",
"Microsoft.EntityFrameworkCore.Tools": {
"version": "1.0.0-preview2-final",
"type": "platform",
"imports": [
"portable-net45+win8+dnxcore50",
"portable-net45+win8"
]
}
}
}
@guybartal don't mix 1.1 and 1.0 packages, update everything to 1.1.
@Tratcher I want to, but I need "WindowsAzure.Storage" which is not compatible with 1.1 yet. any recommendations?
why azure web app expecting Microsoft.AspNetCore.Hosting, Version=1.1.0.0 if all my packages are 1.0?
Downgrade your Microsoft.Extensions packages to 1.0 then. Microsoft.Extensions and Microsoft.AspNetCore version together.
@Tratcher
oops, I missed that somehow,
i've just tried downgrading Microsoft.Extensions packages to 1.0.1 and even 1.0.0 on all packages, but still got the same error (only on azure web app).
here's my current project.json, what am I missing now?:
{
"buildOptions": {
"emitEntryPoint": true,
"preserveCompilationContext": true
},
"dependencies": {
"Microsoft.ApplicationInsights.AspNetCore": "1.0.0",
"Microsoft.AspNetCore.Authentication.Cookies": "1.0.0",
"Microsoft.AspNetCore.Authentication.OpenIdConnect": "1.0.0",
"Microsoft.AspNetCore.Authorization": "1.0.0",
"Microsoft.AspNetCore.Diagnostics": "1.0.0",
"Microsoft.AspNetCore.Mvc": "1.0.0",
"Microsoft.AspNetCore.Mvc.Core": "1.0.0",
"Microsoft.AspNetCore.Mvc.TagHelpers": "1.0.0",
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.0",
"Microsoft.AspNetCore.StaticFiles": "1.0.0",
"Microsoft.EntityFrameworkCore.SqlServer": "1.0.0",
"Microsoft.Extensions.Configuration.Binder": "1.0.0",
"Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
"Microsoft.Extensions.Configuration.FileExtensions": "1.0.0",
"Microsoft.Extensions.Configuration.Json": "1.0.0",
"Microsoft.Extensions.Logging": "1.0.0",
"Microsoft.Extensions.Logging.Console": "1.0.0",
"Microsoft.Extensions.Logging.Debug": "1.0.0",
"Microsoft.IdentityModel.Protocols.OpenIdConnect": "2.0.0",
"Microsoft.NETCore.App": "1.0.0",
"Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.1.0",
"Newtonsoft.Json": "9.0.1",
"WindowsAzure.Storage": "7.2.1"
},
"frameworks": {
"netcoreapp1.0": {
"imports": [
"dotnet5.6",
"portable-net45+win8"
]
}
},
"publishOptions": {
"include": [
"wwwroot",
"Views",
"web.config",
"appsettings.json",
"appsettings.*.json",
"LICENSE.txt"
]
},
"runtimeOptions": {
"gcServer": true
},
"runtimes": {
"win10-x64": {},
"win7-x64": {}
},
"scripts": {
//"prepublish": [ "npm install", "npm recompileapp" ],
"postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
},
"tools": {
"Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final",
}
}
SOLVED!
created new asp.net core app and copy it's project.json missing parts,
I think what fixed it was missing "type": "platform" on "Microsoft.NETCore.App"
thank you for your time @Tratcher !
{
"dependencies": {
"Microsoft.NETCore.App": {
"version": "1.0.1",
"type": "platform"
},
"Microsoft.AspNetCore.Razor.Tools": {
"version": "1.0.0-preview2-final",
"type": "build"
},
"Microsoft.ApplicationInsights.AspNetCore": "1.0.0",
"Microsoft.AspNetCore.Authentication.Cookies": "1.0.0",
"Microsoft.AspNetCore.Authentication.OpenIdConnect": "1.0.0",
"Microsoft.AspNetCore.Authorization": "1.0.0",
"Microsoft.AspNetCore.Diagnostics": "1.0.0",
"Microsoft.AspNetCore.Mvc": "1.0.0",
"Microsoft.AspNetCore.Mvc.Core": "1.0.0",
"Microsoft.AspNetCore.Mvc.TagHelpers": "1.0.0",
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.0",
"Microsoft.AspNetCore.StaticFiles": "1.0.0",
"Microsoft.EntityFrameworkCore.SqlServer": "1.0.0",
"Microsoft.Extensions.Configuration.Binder": "1.0.0",
"Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
"Microsoft.Extensions.Configuration.FileExtensions": "1.0.0",
"Microsoft.Extensions.Configuration.Json": "1.0.0",
"Microsoft.Extensions.Logging": "1.0.0",
"Microsoft.Extensions.Logging.Console": "1.0.0",
"Microsoft.Extensions.Logging.Debug": "1.0.0",
"Microsoft.IdentityModel.Protocols.OpenIdConnect": "2.0.0",
"Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0",
"Newtonsoft.Json": "9.0.1",
"WindowsAzure.Storage": "7.2.1"
},
"frameworks": {
"netcoreapp1.0": {
"imports": [
"dotnet5.6",
"portable-net45+win8"
]
}
},
"publishOptions": {
"include": [
"wwwroot",
"Views",
"web.config",
"appsettings.json",
"appsettings.*.json",
"LICENSE.txt"
]
},
"buildOptions": {
"emitEntryPoint": true,
"preserveCompilationContext": true
},
"runtimeOptions": {
"configProperties": {
"System.GC.Server": true
}
},
"runtimes": {
"win10-x64": {},
"win7-x64": {}
},
"scripts": {
//"prepublish": [ "npm install", "npm recompileapp" ],
"postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
},
"tools": {
"BundlerMinifier.Core": "2.0.238",
"Microsoft.AspNetCore.Razor.Tools": "1.0.0-preview2-final",
"Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final"
}
}
I had the similar problem for Microsoft.AspNetCore.Http.Features package and I fixed it by adding assembly redirect into app.config:
xml
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Microsoft.AspNetCore.Http.Features" publicKeyToken="adb9793829ddae60" culture="neutral" />
<bindingRedirect oldVersion="1.0.0.0" newVersion="1.1.0.0" />
</dependentAssembly>
</assemblyBinding>
Alternatively I resolved this problem by removing Microsoft.VisualStudio.Web.BrowserLink.Loader v14.1.0 package (which depends on Microsoft.AspNetCore.Http.Features). But I didn't want that since I want browser link feature.
@hikalkan
I had the same issue with Microsoft.AspNetCore.Http.Features as well.
I resolved it by replacing Microsoft.VisualStudio.Web.BrowserLink.Loader v14.1.0 with
Microsoft.VisualStudio.Web.BrowserLink v1.0.0
I started using VS 2017 RC. The default template of ASP.NET MVC Core is working properly.
If the project uses the Individual accounts (Identity + EF) the problem occurs. It was working properly initially with all V 1.0.0 Core packages. However, after upgrading all packages to 1.1.0
It seems that the Web.BrowserLink.Loader v14.1.0 or other packages) uses an old reference to old Features 1.0
LOG: Post-policy reference: Microsoft.AspNetCore.Http.Features, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60
LOG: Attempting download of new URL file:///d:/doc/visual studio 2017/Projects/WebApplication4/src/WebApplication4/bin/Debug/net462/Microsoft.AspNetCore.Http.Features.DLL.
WRN: Comparing the assembly name resulted in the mismatch: Minor Version
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.
@zarinbal
It's interesting that there are two packages. And also https://www.nuget.org/packages/Microsoft.VisualStudio.Web.BrowserLink download count is just 131 :)
Does anyone know why there are two packages and which one we should use?
These steps helped me:
bin
folderproject.lock.json
fileThanks a lot!
For whom still getting the Microsoft.AspNetCore.Http.Features / Microsoft.AspNetCore.Server.Kestrel[13] error below, on VS 2015.
Try uncheck "Enable Browser Link" at visual studio and set UseBrowserLink() on Startup.cs.
You will need also reference "Microsoft.VisualStudio.Web.BrowserLink.Loader" at project.json.
That's works for me, probably is a Visual Studio issue.
https://github.com/IdentityServer/IdentityServer4/issues/703
Comment out //app.AddBrowserLink();
works for me!
I had similar issue but it started working by deleting bin folder.
But don't know why it started working. I have my app running initially but when I switched to different app and switch back to the app then it stopped working. Whenever I started debugging and it crashed with the exception at the program.cs said "Can't load Microsoft.AspNetCore.Hosting 1.1.0.0"
I have a new web project created with full .NET framework in Visual Studio 2017 using the setup below:
Full project source code is available at GitHub.
Further configuration:
The error is as follow:
System.IO.FileLoadException: 'Could not load file or assembly 'Microsoft.AspNetCore.Hosting.Abstractions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)'
Anyone has an idea how can I fix it?
@imkheong I had the same issue (targeting net46). I started a new core project, added a unit test project, change both projects to net46 and had to add the binding related properties from here:
AspNetCore.TestHost: https://github.com/aspnet/Hosting/issues/926
This issue is being closed because it has not been updated in 3 months.
We apologize if this causes any inconvenience. We ask that if you are still encountering this issue, please log a new issue with updated information and we will investigate.
Most helpful comment
You might have stray binaries \ app.config in your bin directory. Does wiping the bin directory and rebuilding work?