System.BadImageFormatException: An attempt was made to load a program with an incorrect format.
See original GitHub issueI have asp.net core 2.1 project which I use 64 bit libwkhtmltox.dll
. Locally all works fine either while debugging or hosting on local iis. However when I host it on server which is win 64 bit OS, exception is thrown as like;
System.AggregateException: One or more errors occurred. (An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)) ---> System.BadImageFormatException: An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)
at DinkToPdf.WkHtmlToXBindings.wkhtmltopdf_init(Int32 useGraphics)
at DinkToPdf.PdfTools.Load()
at DinkToPdf.BasicConverter.Convert(IDocument document)
at DinkToPdf.SynchronizedConverter.<>n__0(IDocument document)
at DinkToPdf.SynchronizedConverter.<>c__DisplayClass5_0.<Convert>b__0()
at System.Threading.Tasks.Task`1.InnerInvoke()
at System.Threading.Tasks.Task.<>c.<.cctor>b__278_1(Object obj)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location where exception was thrown ---
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot)
--- End of inner exception stack trace ---
at DinkToPdf.SynchronizedConverter.Invoke[TResult](Func`1 delegate)
at DinkToPdf.SynchronizedConverter.Convert(IDocument document)
deps.json configuration is as follows
{
"runtimeTarget": {
"name": ".NETCoreApp,Version=v2.1",
"signature": "17c0d97ba89af48f20c96c6f42ea9f22e1c7de55"
},
"compilationOptions": {
"defines": [
"TRACE",
"RELEASE",
"NETCOREAPP",
"NETCOREAPP2_1"
],
"languageVersion": "",
"platform": "AnyCPU",
"allowUnsafe": false,
"warningsAsErrors": false,
"optimize": true,
"keyFile": "",
"emitEntryPoint": true,
"xmlDoc": false,
"debugType": "portable"
},
"targets": {
".NETCoreApp,Version=v2.1": {
"KatefWeb/1.0.0": {
"dependencies": {
"Dapper": "1.50.5",
"Dapper.Contrib": "1.50.5",
"DinkToPdf": "1.0.8",
"Katef.Core": "1.0.0",
"Microsoft.AspNetCore.App": "2.1.1",
"Microsoft.NETCore.App": "2.1.0",
"Microsoft.VisualStudio.Web.CodeGeneration.Design": "2.1.1",
"Serilog": "2.8.0",
"Serilog.AspNetCore": "2.1.1",
"Serilog.Settings.Configuration": "3.0.1",
"Serilog.Sinks.MSSqlServer": "5.1.2",
"System.Drawing.Common": "4.5.1"
},
Publishing with options Portable
and Framework-Dependent
.
Issue Analytics
- State:
- Created 4 years ago
- Comments:14
Top Results From Across the Web
System.BadImageFormatException An attempt was made ...
BadImageFormatException An attempt was made to load a program with an incorrect format ... I'm writing a plug-in for another program that is...
Read more >BadImageFormatException in .NET applications
"An attempt was made to load a program with an incorrect format" means that you are trying to load a DLL that is...
Read more >System.BadImageFormatException: An attempt was made ...
System.BadImageFormatException: An attempt was made to load a program with an incorrect format. (0x8007000B). dll import in Azure function.
Read more >System.BadImageFormatException when building as x64
Application' or one of its dependencies. An attempt was made to load a program with an incorrect format." and in more detail: "System....
Read more >BadImageFormatException: An attempt was made to load a ...
The exception that is thrown when the file image of a dynamic link library (DLL) or an executable program is invalid. If you...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
As I know this exception is a 64 bit/ 32 bit conflict in general, I replaced the dll on server with a 32 bit one and exception gone, but I don’t know why.
Could you share an example project? It does not work for me at all. I have even created an independent issue. No matter what I try it just doesn’t work and the error is the same.