Kestrel BadImageFormatException
See original GitHub issueSteps to reproduce
Create a new webAPI from the command line dotnet new webapi
Run from the console dot new run
Visit the http or https URL for example: http://localhost:16767/api/values
Expected behavior
Expect to see the Json formatted response of the basic GET, value1 and value 2
Actual behavior
Following is desplayed in console:
fail: Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv[0]
UvAllocCb
System.BadImageFormatException: Bad IL format.
at System.Buffers.OwnedMemory1.Pin(Int32 byteOffset) at System.Memory
1.Retain(Boolean pin)
at Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.LibuvConnection.OnAlloc(UvStreamHandle handle, Int32 suggestedSize)
at Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.LibuvConnection.<>c.<.cctor>b__24_1(UvStreamHandle handle, Int32 suggestedsize, Object state)
at Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.Networking.UvStreamHandle.UvAllocCb(IntPtr handle, Int32 suggested_size, uv_buf_t& buf)
Unhandled Exception: System.BadImageFormatException: Bad IL format.
at System.Buffers.OwnedMemory1.Pin(Int32 byteOffset) at System.Memory
1.Retain(Boolean pin)
at Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.LibuvConnection.OnAlloc(UvStreamHandle handle, Int32 suggestedSize)
at Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.LibuvConnection.<>c.<.cctor>b__24_1(UvStreamHandle handle, Int32 suggestedsize, Object state)
at Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.Networking.UvStreamHandle.UvAllocCb(IntPtr handle, Int32 suggested_size, uv_buf_t& buf)
at Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.Networking.UvStreamHandle.<>c.<.cctor>b__20_1(IntPtr handle, Int32 suggested_size, uv_buf_t& buf)
at Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.Networking.LibuvFunctions.NativeMethods.uv_run(UvLoopHandle handle, Int32 mode)
at Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.Networking.LibuvFunctions.run(UvLoopHandle handle, Int32 mode)
at Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.LibuvThread.ThreadStart(Object parameter)
— End of stack trace from previous location where exception was thrown —
at Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.LibuvThread.StopAsync(TimeSpan timeout)
at Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.LibuvTransport.StopAsync()
at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServer.StopAsync(CancellationToken cancellationToken)
at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServer.StopAsync(CancellationToken cancellationToken)
at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServer.Dispose()
at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope.Dispose()
at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.Dispose()
at Microsoft.Extensions.DependencyInjection.ServiceProvider.Dispose()
at Microsoft.AspNetCore.Hosting.Internal.WebHost.Dispose()
at Microsoft.AspNetCore.Hosting.WebHostExtensions.RunAsync(IWebHost host, CancellationToken token, String shutdownMessage)
at Microsoft.AspNetCore.Hosting.WebHostExtensions.RunAsync(IWebHost host, CancellationToken token)
at Microsoft.AspNetCore.Hosting.WebHostExtensions.Run(IWebHost host)
at myApi.Program.Main(String[] args) in d:\dev\myApi\Program.cs:line 17
Environment data
dotnet --info
output:
.NET Command Line Tools (2.1.300-preview2-008044)
Product Information: Version: 2.1.300-preview2-008044 Commit SHA-1 hash: c22f7e29a0
Runtime Environment: OS Name: Windows OS Version: 10.0.16299 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\2.1.300-preview2-008044\
Microsoft .NET Core Shared Framework Host
Version : 2.1.0-preview2-26130-06 Build : b13a0d5c331f374afd35ded57b9a4b4ab128864c
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (2 by maintainers)
Top GitHub Comments
The issue has been fixed in kestrel https://github.com/aspnet/KestrelHttpServer/issues/2271 but it hasn’t propagated through all the build layers as yet.
@livarcocc closing this as this is an ASP.NET issue. 😃