Page 1 of 1
UnauthorizedAccessException during report compilation
Posted: Wed Mar 06, 2013 9:24 pm
by allo_man
We are deploying our MVC application on host.
All of our templates (.mrt) are deployed in a Templates folder and we are loading them from a Server.MapPath("~/...")
I found a similar question
http://forum.stimulsoft.com/viewtopic.p ... ied#p19884 your solution was to give access to the folder which I did.
In order to make the application work, I had to give the EVERYONE user Execute access at Server.MapPath("~"). It's like the stimulsoft class wasn't running inside of the security context of the application pool (ASP.Net user)
Can you explain me why and can it be modified to make the application work under ASP.Net credentials (Application pool).
Re: UnauthorizedAccessException during report compilation
Posted: Thu Mar 07, 2013 7:09 am
by Alex K.
Hello,
Unfortunately, it is difficult to say something on this issue. Possibly you need to make some settings on the server associated with the security settings.
Thank you.
Re: UnauthorizedAccessException during report compilation
Posted: Thu Mar 07, 2013 2:08 pm
by allo_man
Thanks, I'll contact my hosting service to learn more about their configuration.
Regards,
Alex
Re: UnauthorizedAccessException during report compilation
Posted: Fri Mar 08, 2013 9:08 am
by Alex K.
Hello,
Ok.
Let us know if you need any additional help.
Thank you.
Re: UnauthorizedAccessException during report compilation
Posted: Fri Mar 15, 2013 5:03 pm
by allo_man
I pinned pointed the error.
After compiling the report, the assembly is removed from the AppDomain and it loaded with no rights. I found two solutions to that problem:
1) Changing the StiConfig.ApplicationDirectory to a temp folder and setting the everyone right on that folder. That is a workaround but still I don't like opening security like that
2) Compiling my report to a dll and adding that dll in reference to my MVC application.
The 2nd option is the best solution for me plus it speed's up the report generation by 3/4 of a second, not negligable for a web application. The only issue I'm getting with that (because it just couldn't work on the first shot) it globalization.
my globalisation code looks like this:
var stiReport = new global::Reports.Certificat_De_Mise_En_Réserve();
stiReport.GlobalizationManager = new GlobalizationManager(reportModel.ResourceType, culture);
stiReport.Render(false);
stiReport.ExportDocument(StiExportFormat.Pdf, filepath);
The problem is that my globalization strings aren't being converted. I'm getting the <GlobalizedName> content istead of the value.
How get I get the compiled report to globalized?
Re: UnauthorizedAccessException during report compilation
Posted: Mon Mar 18, 2013 1:29 pm
by HighAley
Hello.
allo_man wrote:How get I get the compiled report to globalized?
It's impossible to globalize compiled report. You should do it before compilation.
So you need to compile report with each culture you use.
Thank you.
Re: UnauthorizedAccessException during report compilation
Posted: Mon Mar 18, 2013 7:47 pm
by allo_man
How can I globalize them?
When I'm compiling the reports I'm running the thread in new CultureInfo("fr-ca"); and I'm compiling them using:
StiReport.CompileReportsToAssembly(targetAssembly, reports, StiReportLanguageType.CSharp);
But the report aren't in the correct language each label is showing the key part of the resx and not the value part.
Additional question: Is there a way to specify the namespace in wich the compiled reports will be created. I'm tried:
StiOptions.Engine.DefaultNamespace = Path.GetFileNameWithoutExtension(targetAssembly);
but it isn't working.
Regards
Re: UnauthorizedAccessException during report compilation
Posted: Tue Mar 19, 2013 8:13 am
by HighAley
Hello.
Please, try to set next static option to avoid UnauthorizedAccessException.
Code: Select all
StiOptions.Engine.AllowSetCurrentDirectory = false;
How do you set Globalization before compilation?
Do you set GlobalizationManager property?
Thank you.
Re: UnauthorizedAccessException during report compilation
Posted: Tue Mar 19, 2013 2:28 pm
by allo_man
I've tried the AllowSetCurrentDirectory to false. It was giving me another UnauthorizedAccessException furter down the code.
For the GlobalizationManager. I wasn't setting it. That solved my issue with globalization.
Is it possible to configure the namespace in witch the report is built?
Re: UnauthorizedAccessException during report compilation
Posted: Thu Mar 21, 2013 12:59 pm
by HighAley
Hello.
allo_man wrote:Is there a way to specify the namespace in wich the compiled reports will be created. I'm tried:
StiOptions.Engine.DefaultNamespace = Path.GetFileNameWithoutExtension(targetAssembly);
but it isn't working.
You should use this code before creating a report.
It's impossible to change NameSpace of already created report.
Thank you.