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

0

I am using a .NET Core 3.1. When I run the project locally, it works fine when I publish it to my Windows Server (windows server 2016) I am getting the following errors: enter image description here

Here is my error log file:

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, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)

   at Microsoft.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, 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

I tried, changing the AppPool on IIS (IIS-10) for the site to both 32-bit & 64-bit, but still yielded the same error. I have been looking around and all I found was the dll files (should be fine since I run them locally and they work) and 32 or 64-bit servers. I can't go forward with this issue, can anyone shed some light into my issue.

asp.net-core-3.1
windows-server-2016
badimageformatexception
typeinitializationexception
asked on Stack Overflow Oct 16, 2020 by Hussam Ahmed • edited Oct 16, 2020 by Hussam Ahmed

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0