Aspose.Slides in Medium Trust Environment

Hi,

I recently upgraded our Aspose.Slides version from 2.5.9.0 to 14.7.0.0

The primary reason I upgraded was because the new environment I run under requires me to run under Medium Trust.

From reading this previous Aspose forum post, I realized that the version I had was not supported under a Medium Trust environment. But now that I have upgraded to 14.7.0.0 I'm still receiving the required permissions error.

Was Medium Trust support removed since 6.0.0? I have also tried downloading the 6.0.0 version of Aspose.Slides however this continues to give me the required permissions cannot be acquired error. So I'm not quite sure what could be wrong

Any help would be greatly appreciated

Hi Mike,

Thank you for the details.

However, we need further details regarding your system environment and application details to further check the issue you are facing. Please share the details with us to give us a better understanding of your issue.

Thanks & Regards,

Owais,

I'm currently programming for the .NET 3.5 Framework and using IIS 7.5 running on Windows 2008 R2. The application is a information management system used internally

Hi Mike,

Thank you for the details.

It would be better if you can create and share a sample application with us to reproduce the issue at our end. This will help in investigation of the issue you are facing.

Thanks & Regards,

Owais,

Attached is a newly created project that is displaying the same error

Hi Mike,

Thank you for sharing the application.

I am able to reproduce your mentioned issue after an initial test. Your issue has been registered in our issue tracking system with issue id:SLIDESNET-35733. You will be notified via this forum thread once we have any update from the development team side.

Thanks & Regards,

I was wondering if this has been resolved. I’m using Aspose.Slides version 14.9.0 and I’m getting permission error using Medium trust.

Required permissions cannot be acquired.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Security.Policy.PolicyException: Required permissions cannot be acquired.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[PolicyException: Required permissions cannot be acquired.]
System.Security.SecurityManager.ResolvePolicy(Evidence evidence, PermissionSet reqdPset, PermissionSet optPset, PermissionSet denyPset, PermissionSet& denied, Boolean checkExecutionPermission) +7612419
System.Security.SecurityManager.ResolvePolicy(Evidence evidence, PermissionSet reqdPset, PermissionSet optPset, PermissionSet denyPset, PermissionSet& denied, Int32& securitySpecialFlags, Boolean checkExecutionPermission) +57

[FileLoadException: Could not load file or assembly ‘Aspose.Slides, Version=14.9.0.0, Culture=neutral, PublicKeyToken=716fcc553a201e56’ or one of its dependencies. Failed to grant minimum permission requests. (Exception from HRESULT: 0x80131417)]
System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection) +0
System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection) +43
System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +127
System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +142

Hi Tan,


Thanks for inquiring Aspose.Slides.

I have observed that you are using Aspose.Slides for .NET 14.9.0 on your end. I request you to please try using Aspose.Slides for .NET 15.5.0 on your first and share the feedback with us if there is still an issue.

Many Thanks,

I tested the latest version of Aspose.Slides and still got the same error.

Hi Tan,


I request you to please share the sample project and provide information about the environment in your operating system. I will investigate the issue further on my end and will associate that with issue ID SLIDESNET-35733 in case I am able to observe that.

Many Thanks,

Sorry I didn’t get back to you sooner, but I’ve updated to the latest version of Aspose.PDF ver 10.6.0. I’m using .Net Framework 4.5.1. When I save the PDF using medium trust, I get the following error:


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: That assembly does not allow partially trusted callers.

Source Error:

Line 98: m_PdfDocument.Save(“RiskDetailedReport.pdf”, SaveType.OpenInBrowser, this.Response);
Line 99: m_PdfDocument.Close();
Line 100: }

If I change the setting the Full Trust, it works just fine.
Here’s an exert of the code since I can’t post the entire code and don’t have time to generate a sample project that does the same thing.
foreach (RiskItem MyRisk in MyRisks)
{
DoRiskItem(MyRisk, MyPortal, m_PdfDocument);
}

HttpContext.Current.Response.ClearContent();
HttpContext.Current.Response.ClearHeaders();
HttpContext.Current.Response.ContentType = “application/pdf”;

m_PdfDocument.Save(“RiskDetailedReport.pdf”, SaveType.OpenInBrowser, this.Response);
m_PdfDocument.Close();

Hi Tan,


I have observed the issue shared by you and it seems related to Aspose.Pdf rather than Aspose.Slides. I will request Aspose.Pdf support team to share its feedback in this regard shortly.

Many Thanks,
Hi Tan,

phamtq:
Sorry I didn't get back to you sooner, but I've updated to the latest version of Aspose.PDF ver 10.6.0. I'm using .Net Framework 4.5.1. When I save the PDF using medium trust, I get the following error:

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: That assembly does not allow partially trusted callers.

Source Error:

Line 98: m_PdfDocument.Save("RiskDetailedReport.pdf", SaveType.OpenInBrowser, this.Response);
Line 99: m_PdfDocument.Close();
Line 100: }

If I change the setting the Full Trust, it works just fine.
Here's an exert of the code since I can't post the entire code and don't have time to generate a sample project that does the same thing.
foreach (RiskItem MyRisk in MyRisks)
{
DoRiskItem(MyRisk, MyPortal, m_PdfDocument);
}

HttpContext.Current.Response.ClearContent();
HttpContext.Current.Response.ClearHeaders();
HttpContext.Current.Response.ContentType = "application/pdf";

m_PdfDocument.Save("RiskDetailedReport.pdf", SaveType.OpenInBrowser, this.Response);
m_PdfDocument.Close();


Thanks for sharing your findings. Please note Aspose .NET components are recommended to run with Full Trust permission set. This is because Aspose .NET component sometimes need to access registry settings and files located in places other than the virtual directory e.g. for reading fonts etc. Furthermore, Aspose .NET components are based on core .NET system classes, some of which also require Full Trust permission to run in some cases. So you need to set Full Trust permission for Aspose.Pdf for .NET.

Please feel free to contact us for any further assistance.

Best Regards,