微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

BadImageFormatException:试图加载格式错误的程序 0x8007000B

如何解决BadImageFormatException:试图加载格式错误的程序 0x8007000B

我正在使用.NET Core 3.1。当我在本地运行项目时,将其发布到Windows Server(Windows Server 2016)时,它运行良好,出现以下错误

enter image description here

这是我的错误日志文件

info: Microsoft.Hosting.Lifetime[0]

      Application started. Press Ctrl+C to shut down.

info: Microsoft.Hosting.Lifetime[0]

      Hosting environment: Development

info: Microsoft.Hosting.Lifetime[0]

      Content root path: 

warn: Microsoft.AspNetCore.HttpsPolicy.HttpsRedirectionMiddleware[3]

      Failed to determine the https port for redirect.

fail: Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware[1]

      An unhandled exception has occurred while executing the request.

System.TypeInitializationException: The type initializer for 'Microsoft.Data.sqlClient.TdsParser' threw an exception.

 ---> System.TypeInitializationException: The type initializer for 'Microsoft.Data.sqlClient.SNILoadHandle' threw an exception.

 ---> System.BadImageFormatException: An attempt was made to load a program with an incorrect format. (0x8007000B)

   at Microsoft.Data.sqlClient.SNINativeMethodWrapper.SNIInitialize(IntPtr pmo)

   at Microsoft.Data.sqlClient.SNINativeMethodWrapper.SNIInitialize()

   at Microsoft.Data.sqlClient.SNILoadHandle..ctor()

   at Microsoft.Data.sqlClient.SNILoadHandle..cctor()

   --- End of inner exception stack trace ---

   at Microsoft.Data.sqlClient.TdsParserStateObjectFactory.get_Encryptionoptions()

   at Microsoft.Data.sqlClient.TdsParser..cctor()

   --- End of inner exception stack trace ---

   at Microsoft.Data.ProviderBase.DbConnectionPool.CheckPoolBlockingPeriod(Exception e)

   at Microsoft.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject,DbConnectionoptions userOptions,DbConnectionInternal oldConnection)

   at Microsoft.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject,DbConnectionInternal oldConnection)

   at Microsoft.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject,UInt32 waitForMultipleObjectsTimeout,Boolean allowCreate,Boolean onlyOneCheckConnection,DbConnectionInternal& connection)

   at Microsoft.Data.ProviderBase.DbConnectionPool.WaitForPendingopen()

--- End of stack trace from prevIoUs location where exception was thrown ---

   at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenDbConnectionAsync(Boolean errorsExpected,CancellationToken cancellationToken)

   at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenDbConnectionAsync(Boolean errorsExpected,CancellationToken cancellationToken)

   at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenAsync(CancellationToken cancellationToken,Boolean errorsExpected)

   at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject,CancellationToken cancellationToken)

   at Microsoft.EntityFrameworkCore.Query.Internal.QueryingEnumerable`1.AsyncEnumerator.InitializeReaderAsync(DbContext _,Boolean result,CancellationToken cancellationToken)

   at Microsoft.EntityFrameworkCore.sqlServer.Storage.Internal.sqlServerExecutionStrategy.ExecuteAsync[TState,TResult](TState state,Func`4 operation,Func`4 verifySucceeded,CancellationToken cancellationToken)

   at Microsoft.EntityFrameworkCore.Query.Internal.QueryingEnumerable`1.AsyncEnumerator.MoveNextAsync()

   at Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.ToListAsync[TSource](IQueryable`1 source,CancellationToken cancellationToken)

   at Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.ToListAsync[TSource](IQueryable`1 source,CancellationToken cancellationToken)

   at ICRProcessor.Monitor.ICRDocumentPendingModel.RunQuery() in C:\Git\ICRProcessor\ICRProcessor.Monitor\Pages\ICRDocumentPending.cshtml.cs:line 88

   at ICRProcessor.Monitor.ICRDocumentPendingModel.OnGetAsync() in C:\Git\ICRProcessor\ICRProcessor.Monitor\Pages\ICRDocumentPending.cshtml.cs:line 70

   at Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.ExecutorFactory.NonGenericTaskHandlerMethod.Execute(Object receiver,Object[] arguments)

   at Micro

我尝试过,将站点的IIS(iis-10)上的AppPool更改为32位和64位,但是仍然产生相同的错误。我一直在环顾四周,发现的只是 dll 文件(应该很好,因为我在本地运行它们并且它们可以工作)和32或64位服务器。我无法解决这个问题,任何人都可以对我的问题有所了解。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?