question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Kestrel BadImageFormatException

See original GitHub issue

Steps 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.Memory1.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.Memory1.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:closed
  • Created 6 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
davidfowlcommented, Feb 5, 2018

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.

1reaction
muratgcommented, Feb 6, 2018

@livarcocc closing this as this is an ASP.NET issue. 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

BadImageFormatException when migrating from ASP.Net ...
I just migrated an ASP.Net Core 1.1 application to the new 2.0 version that was just released. Now I get the following exception:...
Read more >
How to fix System.BadImageFormatException
I have a project with a method that uses a DLL from another project. It used to work just fine, but now when...
Read more >
NCrunch, Core 1.0.1 and BadImageFormatException
Hi, This works for me, to a large extent. I still get errors in the selfhosted tests with Kestrel, due to Kestrel relying...
Read more >
Publishing to IIS - ASP.NET Core Documentation
The module creates the reverse-proxy between IIS and the Kestrel server. ... BadImageFormatException: Could not load file or assembly 'teststandalone.dll' ...
Read more >
Installation failure, nopcommerce 4.1 on IIS (remote server)
BadImageFormatException : Could not load file or assembly 'Microsoft.AspNetCore. ... at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found