Aspnetcore: ASP.NET Core 2.1.0-preview2-final Applications Crash On Start

Created on 10 Apr 2018  Â·  11Comments  Â·  Source: dotnet/aspnetcore

After upgrading the default Emtpy project (VS 15.7 Preview 3) to 2.1.0-preview2-final and published as self-contained app (win-x64), the app crashes on start with the following exception:

Unhandled Exception: System.IO.IOException: Failed to bind to address http://localhost:5000. ---> System.AggregateException: One or more errors occurred. (Method 'Rent' in type 'System.Buffers.SlabMemoryPool' from assembly 'Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions, Version=2.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' does not have an implementation.) (Method 'Rent' in type 'System.Buffers.SlabMemoryPool' from assembly 'Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions, Version=2.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' does not have an implementation.) ---> System.TypeLoadException: Method 'Rent' in type 'System.Buffers.SlabMemoryPool' from assembly 'Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions, Version=2.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' does not have an implementation.
   at Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions.Internal.KestrelMemoryPool.Create()
   at Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.SocketTransport..ctor(IEndPointInformation endPointInformation, IConnectionDispatcher dispatcher, IApplicationLifetime applicationLifetime, Int32 ioQueueCount, ISocketsTrace trace)
   at Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.SocketTransportFactory.Create(IEndPointInformation endPointInformation, IConnectionDispatcher dispatcher)
   at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServer.<>c__DisplayClass22_0`1.<<StartAsync>g__OnBind|0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.<BindEndpointAsync>d__3.MoveNext()
   at Microsoft.AspNetCore.Server.Kestrel.Core.LocalhostListenOptions.<BindAsync>d__2.MoveNext()
   --- End of inner exception stack trace ---
   --- End of inner exception stack trace ---
   at Microsoft.AspNetCore.Server.Kestrel.Core.LocalhostListenOptions.<BindAsync>d__2.MoveNext()
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.DefaultAddressStrategy.<BindAsync>d__0.MoveNext()
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.<BindAsync>d__0.MoveNext()
   at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServer.<StartAsync>d__22`1.MoveNext()
   at Microsoft.AspNetCore.Hosting.Internal.WebHost.<StartAsync>d__26.MoveNext()
   at Microsoft.AspNetCore.Hosting.WebHostExtensions.<RunAsync>d__5.MoveNext()
   at Microsoft.AspNetCore.Hosting.WebHostExtensions.<RunAsync>d__4.MoveNext()
   at Microsoft.AspNetCore.Hosting.WebHostExtensions.Run(IWebHost host)
   at example.Program.Main(String[] args)

After upgrading the default MVC project (VS 15.7 Preview 3) to 2.1.0-preview2-final and published as self-contained app (win-x64), the app crashes on start with the following exceptions:

fail: Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingProvider[48]
      An error occurred while reading the key ring.
System.TypeLoadException: Could not load type 'System.MemoryExtensions' from assembly 'System.Memory, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'.
   at System.IO.FindEnumerableFactory.NormalizeInputs(String& directory, String& expression)
   at System.IO.FileSystem.EnumerateFileSystemInfos(String fullPath, String searchPattern, SearchOption searchOption, SearchTarget searchTarget)
   at System.IO.DirectoryInfo.EnumerateFileSystemInfos(String searchPattern, SearchOption searchOption)
   at Microsoft.AspNetCore.DataProtection.Repositories.FileSystemXmlRepository.<GetAllElementsCore>d__11.MoveNext()
   at System.Collections.Generic.List`1.AddEnumerable(IEnumerable`1 enumerable)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at Microsoft.AspNetCore.DataProtection.Repositories.FileSystemXmlRepository.GetAllElements()
   at Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager.GetAllKeys()
   at Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingProvider.CreateCacheableKeyRingCore(DateTimeOffset now, IKey keyJustAdded)
   at Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingProvider.Microsoft.AspNetCore.DataProtection.KeyManagement.Internal.ICacheableKeyRingProvider.GetCacheableKeyRing(DateTimeOffset now)
   at Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingProvider.GetCurrentKeyRingCore(DateTime utcNow)
warn: Microsoft.AspNetCore.Server.Kestrel[0]
      Unable to bind to http://localhost:5000 on the IPv4 loopback interface: 'Method 'Rent' in type 'System.Buffers.SlabMemoryPool' from assembly 'Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions, Version=2.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' does not have an implementation.'.
warn: Microsoft.AspNetCore.Server.Kestrel[0]
      Unable to bind to http://localhost:5000 on the IPv6 loopback interface: 'Method 'Rent' in type 'System.Buffers.SlabMemoryPool' from assembly 'Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions, Version=2.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' does not have an implementation.'.
crit: Microsoft.AspNetCore.Server.Kestrel[0]
      Unable to start Kestrel.
System.IO.IOException: Failed to bind to address http://localhost:5000. ---> System.AggregateException: One or more errors occurred. (Method 'Rent' in type 'System.Buffers.SlabMemoryPool' from assembly 'Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions, Version=2.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' does not have an implementation.) (Method 'Rent' in type 'System.Buffers.SlabMemoryPool' from assembly 'Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions, Version=2.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' does not have an implementation.) ---> System.TypeLoadException: Method 'Rent' in type 'System.Buffers.SlabMemoryPool' from assembly 'Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions, Version=2.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' does not have an implementation.
   at Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions.Internal.KestrelMemoryPool.Create()
   at Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.SocketTransport..ctor(IEndPointInformation endPointInformation, IConnectionDispatcher dispatcher, IApplicationLifetime applicationLifetime, Int32 ioQueueCount, ISocketsTrace trace)
   at Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.SocketTransportFactory.Create(IEndPointInformation endPointInformation, IConnectionDispatcher dispatcher)
   at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServer.<>c__DisplayClass22_0`1.<<StartAsync>g__OnBind|0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.<BindEndpointAsync>d__3.MoveNext()
   at Microsoft.AspNetCore.Server.Kestrel.Core.LocalhostListenOptions.<BindAsync>d__2.MoveNext()
   --- End of inner exception stack trace ---
   --- End of inner exception stack trace ---
   at Microsoft.AspNetCore.Server.Kestrel.Core.LocalhostListenOptions.<BindAsync>d__2.MoveNext()
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.DefaultAddressStrategy.<BindAsync>d__0.MoveNext()
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.<BindAsync>d__0.MoveNext()
   at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServer.<StartAsync>d__22`1.MoveNext()

Unhandled Exception: System.IO.IOException: Failed to bind to address http://localhost:5000. ---> System.AggregateException: One or more errors occurred. (Method 'Rent' in type 'System.Buffers.SlabMemoryPool' from assembly 'Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions, Version=2.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' does not have an implementation.) (Method 'Rent' in type 'System.Buffers.SlabMemoryPool' from assembly 'Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions, Version=2.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' does not have an implementation.) ---> System.TypeLoadException: Method 'Rent' in type 'System.Buffers.SlabMemoryPool' from assembly 'Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions, Version=2.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' does not have an implementation.
   at Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions.Internal.KestrelMemoryPool.Create()
   at Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.SocketTransport..ctor(IEndPointInformation endPointInformation, IConnectionDispatcher dispatcher, IApplicationLifetime applicationLifetime, Int32 ioQueueCount, ISocketsTrace trace)
   at Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.SocketTransportFactory.Create(IEndPointInformation endPointInformation, IConnectionDispatcher dispatcher)
   at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServer.<>c__DisplayClass22_0`1.<<StartAsync>g__OnBind|0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.<BindEndpointAsync>d__3.MoveNext()
   at Microsoft.AspNetCore.Server.Kestrel.Core.LocalhostListenOptions.<BindAsync>d__2.MoveNext()
   --- End of inner exception stack trace ---
   --- End of inner exception stack trace ---
   at Microsoft.AspNetCore.Server.Kestrel.Core.LocalhostListenOptions.<BindAsync>d__2.MoveNext()
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.DefaultAddressStrategy.<BindAsync>d__0.MoveNext()
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.<BindAsync>d__0.MoveNext()
   at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServer.<StartAsync>d__22`1.MoveNext()
   at Microsoft.AspNetCore.Hosting.Internal.WebHost.<StartAsync>d__26.MoveNext()
   at Microsoft.AspNetCore.Hosting.WebHostExtensions.<RunAsync>d__5.MoveNext()
   at Microsoft.AspNetCore.Hosting.WebHostExtensions.<RunAsync>d__4.MoveNext()
   at Microsoft.AspNetCore.Hosting.WebHostExtensions.Run(IWebHost host)
   at WebApplication2.Program.Main(String[] args) in D:\WebApplication2\WebApplication2\Program.cs:line 18

Note: Line 18 comes after CreateWebHostBuilder(args).Build().Run();

With ASP.NET Core 2.1.0-preview1-final everything works as expected.

Most helpful comment

Ok. You should be able to fix this in by either...

  1. Updating your implicit package reference to Microsoft.NETCore.App to preview2 like this.
<PropertyGroup>
  <RuntimeFrameworkVersion>2.1.0-preview2-26406-04</RuntimeFrameworkVersion>
</PropertyGroup>
  1. Or, updating to the 2.1.300-preview2 SDK (which updates the implicit package reference to M.N.A for you)

All 11 comments

It sounds to me like you probably have a mismatch of Microsoft.NETCore.App and Microsoft.AspNetCore.App. Did you install the 2.1.300-preview2 SDK? This would happen if you only installed the preview1 SDK. Can you share your deps.json file or the project.assets.json file in the obj/ folder? I have a hunch it will show that you are using Microsoft.NETCore.App 2.1.0-preview1.

You're right @natemcmaster , Microsoft.NETCore.App is still on 2.1.0-preview1-26216-03! Obviously, NuGet manager won't allow updating Microsoft.NETCore.App to 2.1.0-preview2-26406-04 even if it's showing up. Hopefully, it's all sorted out until .NET/ASP.NET Core 4.0 gets shipped. :)

Ok. You should be able to fix this in by either...

  1. Updating your implicit package reference to Microsoft.NETCore.App to preview2 like this.
<PropertyGroup>
  <RuntimeFrameworkVersion>2.1.0-preview2-26406-04</RuntimeFrameworkVersion>
</PropertyGroup>
  1. Or, updating to the 2.1.300-preview2 SDK (which updates the implicit package reference to M.N.A for you)

Thank you, @natemcmaster ! That worked! However, there are a bunch of other issues related to 2.1.0-preview2-final, and especially to Visual Studio 2017 15.7 Preview 3, so it's time to take a hiatus from .NET/ASP.NET Core until Microsoft comes up with something that's more stable and reliable. Already spent too much time with chasing rainbows. Again, thank you very much indeed for your help! Good job!

Totally understand that playing with preview bits can be painful, so thanks for giving it a try. If there are specific issues I can help with, let me know. We're hoping to polish up 2.1.0 soon. This is the best time to let us know about problems because we still have some time to get in fixes.

Okay @natemcmaster, @pranavkm , here's one issue.

Setting

<GenerateAssemblyInfo>false</GenerateAssemblyInfo>

in the csproj file prevents Razor assembly info generation (affecting app.dll and app.Views.dll) and such MVC apps throw when deployed to production servers because views are not found.

@rynowak @pranavkm sounds like an issue in the new Razor SDK.

@rockerinthelocker can you share details about the error message you see in a new issue on https://github.com/aspnet/Razor. Thanks for reporting.

@natemcmaster , Done!

Ok. You should be able to fix this in by either...

  1. Updating your implicit package reference to Microsoft.NETCore.App to preview2 like this.
<PropertyGroup>
  <RuntimeFrameworkVersion>2.1.0-preview2-26406-04</RuntimeFrameworkVersion>
</PropertyGroup>
  1. Or, updating to the 2.1.300-preview2 SDK (which updates the implicit package reference to M.N.A for you)

I have same problem, Can i know how to solve this problem in detail, 1, where to add the code? how to update to preview2 SDK ? Thank you!

FYI we recommend not using 2.1-preview2 as 2.1 has already released: https://dotnet.microsoft.com/download/dotnet-core/2.1. Please download the latest 2.1 SDK and use that instead.

How can I uninstall the old version safely? Thank you!

Get Outlook for iOShttps://aka.ms/o0ukef


From: Justin Kotalik notifications@github.com
Sent: Sunday, December 2, 2018 1:24 AM
To: aspnet/AspNetCore
Cc: Ma, E; Comment
Subject: Re: [aspnet/AspNetCore] ASP.NET Core 2.1.0-preview2-final Applications Crash On Start (#3041)

FYI we recommend not using 2.1-preview2 as 2.1 has already released: https://dotnet.microsoft.com/download/dotnet-core/2.1. Please download the latest 2.1 SDK and use that instead.

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHubhttps://github.com/aspnet/AspNetCore/issues/3041#issuecomment-443490273, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AlNIM9kdrEfByZor4-0SUEEngEQG4N02ks5u044kgaJpZM4TOWNi.

Was this page helpful?
0 / 5 - 0 ratings