我制作了一个 ASP.NET Core (.Net 5) Web API,它在我的本地计算机上运行得非常好。实际上,除了一个 Controller 之外,所有 Controller 都工作正常。当我向 DataStoreController 发出发布请求时,出现以下异常:
System.BadImageFormatException: Bad binary signature. (0x80131192)
at System.Runtime.CompilerServices.RuntimeHelpers._CompileMethod(RuntimeMethodHandleInternal method) at System.Reflection.Emit.DynamicMethod.CreateDelegate(Type delegateType, Object target) at System.Linq.Expressions.Compiler.LambdaCompiler.Compile(LambdaExpression lambda) at System.Linq.Expressions.Expression`1.Compile() at Microsoft.Extensions.Internal.ObjectMethodExecutor.GetExecutor(MethodInfo methodInfo, TypeInfo targetTypeInfo) at Microsoft.Extensions.Internal.ObjectMethodExecutor..ctor(MethodInfo methodInfo, TypeInfo targetTypeInfo, Object[] parameterDefaultValues) at Microsoft.Extensions.Internal.ObjectMethodExecutor.Create(MethodInfo methodInfo, TypeInfo targetTypeInfo, Object[] parameterDefaultValues) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvokerCache.GetCachedResult(ControllerContext controllerContext) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvokerProvider.OnProvidersExecuting(ActionInvokerProviderContext context) at Microsoft.AspNetCore.Mvc.Infrastructure.ActionInvokerFactory.CreateInvoker(ActionContext actionContext) at Microsoft.AspNetCore.Mvc.Routing.ActionEndpointFactory.<>c__DisplayClass7_0.b__0(HttpContext context) at Microsoft.AspNetCore.Routing.EndpointMiddleware.Invoke(HttpContext httpContext) --- End of stack trace from previous location --- at Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIMiddleware.Invoke(HttpContext httpContext) at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider) at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
我已经尝试过如果我将 Controller 内的方法设置为空并仅返回 null 会发生什么 - 但仍然是相同的错误。与其他 Controller 在包方面的唯一区别是 DataStoreController 使用 Stackexchange.Redis NuGet 包。
我的直觉告诉我,这是一个奇怪的 Azure Bug,但我很想从你那里得到一些意见/建议/答案。
最佳答案
好吧好吧。我已经找到了解决方案。
我停止并启动了应用服务,现在一切正常。这实际上可能是一个奇怪的 Azure 问题。
关于c# - Azure 应用服务中的 System.BadImageFormatException : Bad binary signature.,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68496331/