The specified executable is not a valid application for this OS platform
-
Hello,
i'm looking for a suitable solution to generate some custom reports in a standalone desktop .NET application and jsreports seems a very nice one!
I've installed NodeJS (12.3.1) and i tried to create a sample project following this tutorial.
I think i'm missing something here, i installed the NuGet packages jsreport.Binary and jsreport.Local and i implemented the first example:
using System.IO; using System.Threading.Tasks; namespace ReportsTest { public class Program { static async Task Main(string[] args) { var rs = new LocalReporting() .UseBinary(JsReportBinary.GetBinary()) .AsUtility() .Create(); var report = await rs.RenderAsync(new RenderRequest { Template = new Template() { Recipe = Recipe.PhantomPdf, Engine = Engine.None, Content = "<style>h1 { color:red }</style><h1> Hello World! </h1>" } }); using (var fs = File.Create("out.pdf")) { report.Content.CopyTo(fs); } } } }
The project is a .NET Core 2.1 Console application.
When i try to run it i get the error "The specified executable is not a valid application for this OS platform"
NodeJs is in my Path and the exception doesn't specify which binary is it talking about, i can guess it is the jsreport executable in jsreport.Binary though..The full exception:
System.ComponentModel.Win32Exception HResult=0x80004005 Message=The specified executable is not a valid application for this OS platform. Source=System.Diagnostics.Process StackTrace: at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo) at System.Diagnostics.Process.Start() at jsreport.Local.Internal.BinaryProcess.<InnerExecute>d__18.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult() at jsreport.Local.Internal.BinaryProcess.<ExecuteExe>d__17.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult() at jsreport.Local.Internal.LocalUtilityReportingService.<RenderAsync>d__10.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() at ReportsTest.Program.<Main>d__0.MoveNext() in E:\Progetti\ReportsTest\ReportsTest\Program.cs:line 20 at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at ReportsTest.Program.<Main>(String[] args)
I tried to change the recipe to use ChromePDF but the result is the same..
I get this error if i run the project for "Any CPU" and "x64". I don't get any error if i run it for "x86", but no output file is generated..
Can anyone help me on this issue?
Thanks
-
Hi,
thejsreport.Binary
dll includes in its manifest the jsreport.exe. This is extracted into your temp during the firstRenderAsync
call and the error you noticed comes from this. Thejsreport.Binary
includes compiledjsreport.exe
for windows x64. In case you run on another platform, you should use a differentjsreport.Binary
.
https://jsreport.net/learn/dotnet-local#windows-linux-macNote, using jsreport.Binary and jsreport.Local doesn't require node.js to be present on the target machine.
In case you are on windows and still get error
The specified executable is not a valid application for this OS platform
, you are maybe running windows 32 bit. Unfortunately, we don't release extra jsreport binary for 32 bit and you can't usejsreport.Local
in this case. However, full jsreport can be used on windows 32 bit, you just need to have proper nodejs installed.
https://jsreport.net/on-prem
When you have full jsreport running, you can use jsreport .net client and connect to it.
-
Thank you for the reply!
I double checked my Windows 10 installation is x64 :)
I found a jsreport.exe file in the temp folder located at
C:\Users\myuser\AppData\Local\Temp\jsreport\dotnet\binary-default-2.4.0.0
i'm not sure if it is the correct one.. i tried to run the exe, but i got the same error.. and then i noticed that the file size is 0!
-
Thanks for checking. This has already happened before. I am not sure how this happens because we reviewed the code and it seems correct.
Maybe windows defender blocks this for some reason.
Please try to deleteC:\Users\myuser\AppData\Local\Temp\jsreport
and try it again.
If it will end up the same. Please try to pause windows defender, delete that folder and try it again.
-
Awesome! it worked!
Anyway i had to give pemissions to node.js server when i run the project..
Now that i think about it, the first time i tried to run it before installing node.js, then i installed it and tried again.
I don't know if it is connected since you said node.js is not needed..but windows asking me to give permissions to it makes me a bit perplexed..Anyway, thank you for your advice and for the hard work on this tool!
-
I tried to run the same report on a machine without node.js installed and with windows defender disabled, i had the same issue.
I tried to delete the jsreport folder and run the project again several times but with the same result.. the extracted jsreport.exe is 0 bytes.Are we sure node.js is not a requirement for jsreport local?
-
tried to delete the jsreport folder and run the project again several times but with the same result.. the extracted jsreport.exe is 0 bytes.
Try to compare jsreport.Binary dlls, are they the same on the server as well as your local?
Are we sure node.js is not a requirement for jsreport local?
Yes we are. In fact
jsreport.exe
is node.js. Just with jsreport compiled into.
-
actually i tried it on another developer machine (i'm working on a desktop application) and installed the same jsreport.Local and Binary NuGet packages..