UnauthorizedAccessException during report compilation

Stimulsoft Reports.WEB discussion
Post Reply
User avatar
allo_man
Posts: 17
Joined: Sun Jun 10, 2012 6:56 am
Location: Canada

UnauthorizedAccessException during report compilation

Post 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).
Last edited by allo_man on Tue May 07, 2013 5:39 pm, edited 1 time in total.
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: UnauthorizedAccessException during report compilation

Post 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.
User avatar
allo_man
Posts: 17
Joined: Sun Jun 10, 2012 6:56 am
Location: Canada

Re: UnauthorizedAccessException during report compilation

Post by allo_man »

Thanks, I'll contact my hosting service to learn more about their configuration.

Regards,
Alex
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: UnauthorizedAccessException during report compilation

Post by Alex K. »

Hello,

Ok.
Let us know if you need any additional help.

Thank you.
User avatar
allo_man
Posts: 17
Joined: Sun Jun 10, 2012 6:56 am
Location: Canada

Re: UnauthorizedAccessException during report compilation

Post 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?
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: UnauthorizedAccessException during report compilation

Post 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.
User avatar
allo_man
Posts: 17
Joined: Sun Jun 10, 2012 6:56 am
Location: Canada

Re: UnauthorizedAccessException during report compilation

Post 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
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: UnauthorizedAccessException during report compilation

Post 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.
User avatar
allo_man
Posts: 17
Joined: Sun Jun 10, 2012 6:56 am
Location: Canada

Re: UnauthorizedAccessException during report compilation

Post 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?
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: UnauthorizedAccessException during report compilation

Post 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.
Post Reply