This is a migrated thread and some comments may be shown as answers.

Medium trust not working

3 Answers 125 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Mattias
Top achievements
Rank 1
Mattias asked on 17 Aug 2009, 12:15 PM
Hi,
I was testing the latest build (3.1.9.807) for the medium trust support with this code:
protected void Page_Init(object sender, EventArgs e) 
        { 
            Swh.Ih7.Reports.ShopInvoice report = new Swh.Ih7.Reports.ShopInvoice(); 
            report.OrderID = new Guid(Request.QueryString["OrderID"]); 
 
            DisplayPDF(report); 
        } 
 
        void DisplayPDF(Telerik.Reporting.Report reportToExport) 
        { 
            ReportProcessor reportProcessor = new ReportProcessor(); 
            RenderingResult result = reportProcessor.RenderReport("PDF", reportToExport, null); 
 
            string fileName = result.DocumentName + ".pdf"
 
            Response.Clear(); 
            Response.ContentType = result.MimeType; 
            Response.Cache.SetCacheability(HttpCacheability.Private); 
            Response.Expires = -1; 
            Response.Buffer = false
 
            Response.AddHeader("Content-Disposition"
                               string.Format("{0};FileName=\"{1}\""
                                             "attachment"
                                             fileName)); 
 
            Response.OutputStream.Write(result.DocumentBytes, 0, result.DocumentBytes.Length); 
            Response.End();  


But I'm getting security exception:
Server Error in '/' Application. 
-------------------------------------------------------------------------------- 
 
Security Exception  
Description: The application attempted to perform an operation not allowed by the security policy.  To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.  
 
Exception Details: System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutralPublicKeyToken=b77a5c561934e089' failed. 
 
Source Error:  
 
 
[No relevant source lines] 
  
 
Source File: App_Web_zzaoc31d.4.cs    Line: 0  
 
Stack Trace:  
 
 
[SecurityException: Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutralPublicKeyToken=b77a5c561934e089' failed.] 
   Telerik.Reporting.Pdf.Rendering.PdfRenderer.DrawString(String text, PdfFont font, Brush brush, RectangleF rect, Boolean rightToLeft) +0 
   Telerik.Reporting.Pdf.Drawing.PdfGraphics.DrawString(String s, Font font, Brush brush, RectangleF rect, StringFormat format) +124 
   Telerik.Reporting.ImageRendering.CanvasPdf.DrawString(String s, Font font, Brush brush, RectangleF rect, StringFormat format) +107 
   Telerik.Reporting.ImageRendering.TextLine.Render() +1436 
   Telerik.Reporting.ImageRendering.RenderingElement.RenderToPage(RectangleRF clip, RoundedFloat parentLeft, RoundedFloat parentTop) +1864 
   Telerik.Reporting.ImageRendering.RenderingElement.RenderChildren(RectangleRF clip) +161 
   Telerik.Reporting.ImageRendering.RenderingElement.RenderToPage(RectangleRF clip, RoundedFloat parentLeft, RoundedFloat parentTop) +1970 
   Telerik.Reporting.ImageRendering.RenderingElement.RenderChildren(RectangleRF clip) +161 
   Telerik.Reporting.ImageRendering.RenderingElement.RenderToPage(RectangleRF clip, RoundedFloat parentLeft, RoundedFloat parentTop) +1970 
   Telerik.Reporting.ImageRendering.CompositionBase.RenderPageSection(PageArea pageArea, RenderingElement pageSection, Single height) +339 
   Telerik.Reporting.ImageRendering.CompositionBase.ApplyPageSections() +311 
   Telerik.Reporting.ImageRendering.CompositionBase.SendPhysicalPages(Boolean force) +52 
   Telerik.Reporting.ImageRendering.CompositionBase.End() +75 
   Telerik.Reporting.ImageRendering.CompositionPdf.End() +39 
   Telerik.Reporting.ImageRendering.CompositionBase.Dispose(Boolean disposing) +22 
   Telerik.Reporting.ImageRendering.CompositionPdf.Dispose(Boolean disposing) +11 
   Telerik.Reporting.ImageRendering.CompositionBase.System.IDisposable.Dispose() +17 
   Telerik.Reporting.ImageRendering.ImageRendererBase.RenderReport(Report report, Hashtable renderingContext, Hashtable deviceInfo, CreateStream createStreamCallback, EvaluateHeaderFooterExpressions evalHeaderFooterCallback) +242 
   Telerik.Reporting.ImageRendering.ImageRendererBase.Telerik.Reporting.Processing.IRenderingExtension.Render(Report report, Hashtable renderingContext, Hashtable deviceInfo, CreateStream createStreamCallback, EvaluateHeaderFooterExpressions evalHeaderFooterCallback) +21 
   Telerik.Reporting.Processing.ReportProcessor.Render(IList`1 reports, ExtensionInfo extensionInfo, Hashtable renderingContext, Hashtable deviceInfo, CreateStream createStreamCallback) +353 
   Telerik.Reporting.Processing.ReportProcessor.RenderReport(String format, IReportDocument reportDocument, Hashtable deviceInfo, CreateStream createStreamCallback, String& documentName) +421 
   Telerik.Reporting.Processing.ReportProcessor.RenderReport(String format, IReportDocument reportDocument, Hashtable deviceInfo) +108 
   Swh.Reports.Web.UI._Default.DisplayPDF(Report reportToExport) +91 
   Swh.Reports.Web.UI._Default.Page_Init(Object sender, EventArgs e) +184 
   System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14 
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35 
   System.Web.UI.Control.OnInit(EventArgs e) +99 
   System.Web.UI.Page.OnInit(EventArgs e) +12 
   System.Web.UI.Control.InitRecursive(Control namingContainer) +333 
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +6785 
   System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +242 
   System.Web.UI.Page.ProcessRequest() +80 
   System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) +21 
   System.Web.UI.Page.ProcessRequest(HttpContext context) +49 
   ASP.ih7shopinvoice_aspx.ProcessRequest(HttpContext context) in App_Web_zzaoc31d.4.cs:0 
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +181 
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75 
 
  
 
 
-------------------------------------------------------------------------------- 
Version Information: Microsoft .NET Framework Version:2.0.50727.3082; ASP.NET Version:2.0.50727.3082  



3 Answers, 1 is accepted

Sort by
0
Chavdar
Telerik team
answered on 17 Aug 2009, 12:23 PM
Hello Mattias,

Currently PDF rendering extension is not working in Medium Trust environment. For more information about what limitations exist when you use Telerik Reporting in medium trust, please refer to the following documentation article: Medium Trust.

All the best,
Chavdar
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Mattias
Top achievements
Rank 1
answered on 17 Aug 2009, 12:37 PM
Ohh, not good! :(
Will this be supported in future release?
Can you specify how to append web_mediumtrust.config in c:\windows\microsoft.net\framework\2.0.50727\config\ so pdf rendering will work?

/Mattias

0
Chavdar
Telerik team
answered on 17 Aug 2009, 01:19 PM
Hi Mattias,

In web_mediumtrust.config find the SecurityPermission class and add the UnmanagedCode flag:

<NamedPermissionSets>
  ...
  <PermissionSet class="NamedPermissionSet" version="1" Name="ASP.Net">
    ...
    <IPermission class="SecurityPermission" version="1" Flags="Assertion, Execution, ControlThread, ControlPrincipal, RemotingConfiguration, UnmanagedCode"/>   
    ...
  </PermissionSet>
</NamedPermissionSets>

Hope this helps.

Best wishes,
Chavdar
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
General Discussions
Asked by
Mattias
Top achievements
Rank 1
Answers by
Chavdar
Telerik team
Mattias
Top achievements
Rank 1
Share this question
or