Invoice pdf in order module is not working order module version is 3.26.0

{“message”:“An exception occurred while processing the request [/api/order/customerOrders/invoice/CO220704-00001]: System.AggregateException: One or more errors occurred. (An attempt was made to load a program with an incorrect format. (0x8007000B))\r\n —> System.BadImageFormatException: An attempt was made to load a program with an incorrect format. (0x8007000B)\r\n at DinkToPdf.WkHtmlToXBindings.wkhtmltopdf_init(Int32 useGraphics)\r\n at DinkToPdf.PdfTools.Load()\r\n at DinkToPdf.BasicConverter.Convert(IDocument document)\r\n at DinkToPdf.SynchronizedConverter.<>n__0(IDocument document)\r\n at DinkToPdf.SynchronizedConverter.<>c__DisplayClass5_0.b__0()\r\n at System.Threading.Tasks.Task1.InnerInvoke()\r\n at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)\r\n --- End of inner exception stack trace ---\r\n at DinkToPdf.SynchronizedConverter.Invoke[TResult](Func1 delegate)\r\n at DinkToPdf.SynchronizedConverter.Convert(IDocument document)\r\n at VirtoCommerce.OrdersModule.Web.Controllers.Api.OrderModuleController.GeneratePdf(String htmlContent) in /home/runner/work/vc-module-order/vc-module-order/src/VirtoCommerce.OrdersModule.Web/Controllers/Api/OrderModuleController.cs:line 629\r\n at VirtoCommerce.OrdersModule.Web.Controllers.Api.OrderModuleController.GetInvoicePdf(String orderNumber) in /home/runner/work/vc-module-order/vc-module-order/src/VirtoCommerce.OrdersModule.Web/Controllers/Api/OrderModuleController.cs:line 542\r\n at lambda_method(Closure , Object )\r\n at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.TaskOfActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object arguments)\r\n at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__Logged|12_1(ControllerActionInvoker invoker)\r\n at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)\r\n at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)\r\n at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)\r\n at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)\r\n at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|24_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)\r\n at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)\r\n at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)\r\n at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|19_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)\r\n at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Logged|17_1(ResourceInvoker invoker)\r\n at Microsoft.AspNetCore.Routing.EndpointMiddleware.g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)\r\n at Microsoft.AspNetCore.Builder.Extensions.MapMiddleware.Invoke(HttpContext context)\r\n at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)\r\n at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)\r\n at VirtoCommerce.Platform.Web.Middleware.ApiErrorWrappingMiddleware.Invoke(HttpContext context) in /home/runner/work/vc-platform/vc-platform/src/VirtoCommerce.Platform.Web/Middleware/ApiErrorWrappingMiddleware.cs:line 46 “,“stackTrace”:” at DinkToPdf.SynchronizedConverter.Invoke[TResult](Func`1 delegate)\r\n at DinkToPdf.SynchronizedConverter.Convert(IDocument document)\r\n at VirtoCommerce.OrdersModule.Web.Controllers.Api.OrderModuleController.GeneratePdf(String htmlContent) in /home/runner/work/vc-module-order/vc-module-order/src/VirtoCommerce.OrdersModule.Web/Controllers/Api/OrderModuleController.cs:line 629\r\n at VirtoCommerce.OrdersModule.Web.Controllers.Api.OrderModuleController.GetInvoicePdf(String orderNumber) in /home/runner/work/vc-module-order/vc-module-order/src/VirtoCommerce.OrdersModule.Web/Controllers/Api/OrderModuleController.cs:line 542\r\n at lambda_method(Closure , Object )\r\n at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.TaskOfActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object arguments)\r\n at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__Logged|12_1(ControllerActionInvoker invoker)\r\n at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)\r\n at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)\r\n at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)\r\n at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)\r\n at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|24_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)\r\n at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)\r\n at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)\r\n at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|19_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)\r\n at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Logged|17_1(ResourceInvoker invoker)\r\n at Microsoft.AspNetCore.Routing.EndpointMiddleware.g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)\r\n at Microsoft.AspNetCore.Builder.Extensions.MapMiddleware.Invoke(HttpContext context)\r\n at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)\r\n at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)\r\n at VirtoCommerce.Platform.Web.Middleware.ApiErrorWrappingMiddleware.Invoke(HttpContext context) in /home/runner/work/vc-platform/vc-platform/src/VirtoCommerce.Platform.Web/Middleware/ApiErrorWrappingMiddleware.cs:line 46”}

As I know this exception is a 64 bit/ 32 bit conflict in general.
Are you running on a 64-bit OS?

If you run in Azure, Check that Platform is 64-bit.

@OlegoO

Yes the OS is 64-bit in Azure. The issue goes away when we manually add DinkToPdf.dll to the platform root folder. We face the same issue in the local development env too.

image

1 Like

Thank you for the feedback.

@OlegoO We checked in azure we also have 64 bit in platform settings but still it’s not working for us

Any other setup is required for this ? like some specific version of module or anything else

Could you try to download correct version of wkhtmltopdf and manually extract wkhtmltopdf files to platform root folder?

ok thanks for the reply