在IIS Express或控制台或docker中运行api时出现以下错误。我怀疑它与糟糕的Visual Studio 2017更新到15.5.4有关,因为我收到了这个警告:无法卸载Microsoft.VisualStudio.Debugger.CoreClr.x64
BadImageFormatException:PE标头中声明的部分数无效。
堆栈跟踪 System.Reflection.PortableExecutable.PEHeaders.ReadSectionHeaders(ref PEBinaryReader reader) System.Reflection.PortableExecutable.PEHeaders..ctor(Stream peStream,int size,bool isLoadedImage) System.Reflection.PortableExecutable.PEReader..ctor(Stream peStream,PEStreamOptions选项,int size) System.Reflection.PortableExecutable.PEReader..ctor(Stream peStream,PEStreamOptions选项) Microsoft.CodeAnalysis.ModuleMetadata.CreateFromStream(Stream peStream,PEStreamOptions选项) Microsoft.AspNetCore.Mvc.Razor.Compilation.MetadataReferenceFeatureProvider.CreateMetadataReference(string path) Microsoft.AspNetCore.Mvc.Razor.Compilation.MetadataReferenceFeatureProvider.PopulateFeature(IEnumerable parts,MetadataReferenceFeature功能) Microsoft.AspNetCore.Mvc.ApplicationParts.ApplicationPartManager.PopulateFeature(TFeature功能) Microsoft.AspNetCore.Mvc.Razor.Internal.DefaultRazorReferenceManager.GetCompilationReferences() System.Threading.LazyInitializer.EnsureInitializedCore(ref T target,ref bool initialized,ref object syncLock,Func valueFactory) Microsoft.AspNetCore.Mvc.Razor.Internal.DefaultRazorReferenceManager.get_CompilationReferences() Microsoft.AspNetCore.Mvc.Razor.Internal.LazyMetadataReferenceFeature.get_References() Microsoft.CodeAnalysis.Razor.CompilationTagHelperFeature.GetDescriptors() Microsoft.AspNetCore.Razor.Language.DefaultRazorTagHelperBinderPhase.ExecuteCore(RazorCodeDocument codeDocument) Microsoft.AspNetCore.Razor.Language.RazorEnginePhaseBase.Execute(RazorCodeDocument codeDocument) Microsoft.AspNetCore.Razor.Language.DefaultRazorEngine.Process(RazorCodeDocument文档) Microsoft.AspNetCore.Razor.Language.RazorTemplateEngine.GenerateCode(RazorCodeDocument codeDocument) Microsoft.AspNetCore.Mvc.Razor.Internal.RazorViewCompiler.CompileAndEmit(string relativePath) Microsoft.AspNetCore.Mvc.Razor.Internal.RazorViewCompiler.CreateCacheEntry(string normalizedPath) System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务) System.Runtime.CompilerServices.TaskAwaiter.GetResult() Microsoft.AspNetCore.Mvc.Razor.Internal.DefaultRazorPageFactoryProvider.CreateFactory(string relativePath) Microsoft.AspNetCore.Mvc.Razor.RazorViewEngine.CreateCacheResult(HashSet expirationTokens,string relativePath,bool isMainPage) Microsoft.AspNetCore.Mvc.Razor.RazorViewEngine.OnCacheMiss(ViewLocationExpanderContext expanderContext,ViewLocationCacheKey cacheKey) Microsoft.AspNetCore.Mvc.Razor.RazorViewEngine.LocatePageFromViewLocations(ActionContext actionContext,string pageName,bool isMainPage) Microsoft.AspNetCore.Mvc.Razor.RazorViewEngine.FindView(ActionContext context,string viewName,bool isMainPage) Microsoft.AspNetCore.Mvc.ViewEngines.CompositeViewEngine.FindView(ActionContext context,string viewName,bool isMainPage) Microsoft.AspNetCore.Mvc.ViewFeatures.Internal.ViewResultExecutor.FindView(ActionContext actionContext,ViewResult viewResult) Microsoft.AspNetCore.Mvc.ViewResult + d__26.MoveNext() System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务) Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker + d__19.MoveNext() System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务) Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker + d__24.MoveNext() System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResultExecutedContext context) Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(ref state next,ref Scope scope,ref object state,ref bool isCompleted) Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker + d__22.MoveNext() System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResourceExecutedContext context) Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(ref state next,ref Scope scope,ref object state,ref bool isCompleted) Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker + d__17.MoveNext() System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务) Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker + d__15.MoveNext() System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务) Microsoft.AspNetCore.Builder.RouterMiddleware + d__4.MoveNext() System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务) Microsoft.AspNetCore.Authentication.AuthenticationMiddleware + d__6.MoveNext() System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务) Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.MigrationsEndPointMiddleware + d__4.MoveNext() System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务) Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.DatabaseErrorPageMiddleware + d__6.MoveNext() System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.DatabaseErrorPageMiddleware + d__6.MoveNext() System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务) Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware + d__7.MoveNext()
更新
尽管重新安装VS2017,我仍然看到同样的错误。任何帮助将得到真正的赞赏。谢谢!