Open JeanCollas opened 6 years ago
Here is the thread discussing this https://forum.jsreport.net/topic/428/asp-net-an-error-has-occurred-when-trying-to-initialize-jsreport/18
I'm far less qualified than Jan to comment, but I'll give a few thoughts! If you error message is "Access is denied", then I would first try running the project as administrator. If that doesn't work, go to every place that jsreports will be accessing (temp folder, folder where you store templates, etc) and make sure the security allows access. If you're using IIS, then you'll have to grant full control to "IUSR" and "IIS_IUSRS"
or it can be also blocked by windows defender...
I know this thread is old, and I don't particularly like to grave-dig, however, I am encountering the same issue, and it has nothing to do with actual authorization.
I have two copies of an ASP.NET Core application deployed to two different environments on the same server, one is development, one is test. I can successfully "run" a report from one or the other; the first process that starts the jsreport engine can render reports, while the other application will get the same error reported by OP JeanCollas.
If I open IIS Manager and stop the site that successfully launches reports, the site that previously threw the above-mentioned error would work. Upon further troubleshooting, I turned on "Load User Profile" in the application pool for the application, and then it throws a different error than the one listed above. The new error more accurately describes the issue; both applications are starting a process at a certain port (5488), and only the first to do so succeeds.
Here is the configuration in the ASP.NET Startup.cs file; please let me know if there is a modification I need to make to it to allow both dev and test instances to co-exist on the same server:
services.AddJsReport(new LocalReporting() .UseBinary(JsReportBinary.GetBinary()) .KillRunningJsReportProcesses() .RunInDirectory(Path.Combine(Directory.GetCurrentDirectory(), "jsreport")) .AsUtility() .Create());
Please use a different port on the second env
services.AddJsReport(new LocalReporting()
.UseBinary(JsReportBinary.GetBinary())
.KillRunningJsReportProcesses()
.RunInDirectory(Path.Combine(Directory.GetCurrentDirectory(), "jsreport"))
.Configure(cfg => {
cfg.HttpPort = 5489;
return cfg
})
.AsUtility()
.Create());
Firstly, Jan, thank you for your dedication to this project. It has been consistent over a LONG period of time. This is truly impressive to me; you have my unabashed respect!
I have made the configuration change you indicated above, and am waiting my turn "in line" to be able to deploy to a shared resource to test.
I will delve further into the documentation to see if I can discern how to make the above change in the web.config or appsettings.json so that I can create appropriate publish profiles to achieve the desired result without having to change code to deploy to various environments (dev, test, prod).
Thank you again!
Thank you. FYI the information is already in the docs git, it just isn't yet live, but it will be soon. Let me know if you have further issues.
Thank you for the link Jan, my issue was resolved by the following:
I implemented the Configure portion in Startup.cs, as you indicated and deployed to the shared environment. I updated both site application pools with "Load User Profile" set to "true". This resolved both the authorization and collision issues.
I then followed your documentation link to learn a bit about using a config file. I removed the configure portion from Startup.cs, and instead set httpPort in a jsreport.config.json file. I deployed the resulting build to the shared environment and confirmed both parallel application were working as intended.
Thank you again Jan!
Woud you see any reason why it would throw an "access denied"?
I have two websites with the exact same code, on the same server, one is working well, the second is not, and throws: