System.BadImageFormatException:错误的二进制签名。在 Azure 应用服务中

System.BadImageFormatException: Bad binary signature. in Azure App Service

我制作了一个 ASP.NET Core (.Net 5) Web API,它在我的本地机器上运行良好。实际上,除了一个控制器外,所有控制器都可以正常工作。当我向我的 DataStoreController 发出 Post 请求时,出现以下异常:

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 中的 Method 设置为空并且 return null 会发生什么 - 但仍然是相同的错误。与其他控制器在包方面的唯一区别是 DataStoreController 使用 Stackexchange.Redis NuGet 包。

我的直觉告诉我这是一个奇怪的 Azure Bug,但我很想从你那里得到一些 opinions/advices/answers。

好的好的。我找到了解决办法。

我停止并启动了应用服务,现在一切正常。这实际上可能是一个奇怪的 Azure 问题。