I am trying to run my Dotnet-Core web Api project in windows 10 machine. But I am facing runtime error. I 'm not allowed to change the Application nuget version too
>fail: Microsoft.AspNetCore.Server.Kestrel[13]
Connection id "0HMLLR56JLU26", Request id "0HMLLR56JLU26:0000000B": An unhandled exception was thrown by the application.
System.BadImageFormatException: Could not load file or assembly 'Microsoft.AspNetCore.Http.Extensions, Version=3.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. Format of the executable (.exe) or library (.dll) is invalid.
File name: 'Microsoft.AspNetCore.Http.Extensions, Version=3.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'
at Microsoft.AspNetCore.StaticFiles.StaticFileContext.get_RequestHeaders
at Microsoft.AspNetCore.StaticFiles.StaticFileContext.ComputeIfMatch()
at Microsoft.AspNetCore.StaticFiles.StaticFileContext.ComprehendRequestHeaders()
at Microsoft.AspNetCore.StaticFiles.StaticFileContext.ServeStaticFile(HttpContext context, RequestDelegate next)
CodePudding user response:
The answer here lies in - BadImageFormatException
. One of these
- Your app is compiled for one architecture (x64 or x86) but your Web Server pool runs different one
- One of the 3rd party DLLs is of incompatible architecture (your case)
- One of your DLLs is of incompatible architecture.
- DLL is compiled for the wrong platform. e.g. running DLL compiled for .net4.8 in the .netcore (your case)