We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com



I just deploy my web application on a hosting windows server and I get the following error when I try to generate a Excel report:

Security Exception <?xml:namespace prefix = "o" ns = "urn:schemas-microsoft-com:office:office" />

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.

The file Excel (report) is correctly generated on a subfolder of my root application, but before IE asked me to open file I get the error

Can anyone help me ?




Well, I am afraid, Aspose.Cells does not work well on partial trust or medium trust mode. Please see the document for your complete reference:

Thank you.

Hi,Thank you for your prompt answer

may I change this setting on web.config file ?


Yes, you may try it, please see the document on how to manipulate/ set trust levels in the configuration file:


Thank you.

I get the error just with just simply this code:

Dim path As String = HttpContext.Current.Server.MapPath("~")
Dim licFile As String = path & "\Aspose.Total.lic"
Dim license As Aspose.Cells.License = New Aspose.Cells.License()

is it possible ? I cannot change trust level!!!


As we told you that Aspose.Cells cannot work well in partial trust or medium trust mode, please see the suggested document for reasons for your complete reference.

By the way for your code segment to set the license issue on medium trust level environment, please try to get the license file into streams and set the license accordingly, see the sample lines of code:
Sample code:

’ Instantiate the License object
Dim lic As New Aspose.Cells.License()
’ Get the license file into stream
Dim stream As System.IO.Stream = System.IO.File.OpenRead(MapPath("~") & “\Aspose.Total.lic”)
’ Set the License stream
’ Close the stream

Thank you.

I tryed also your sample code, but I had the same error ... at the end I chenge trust configuration in web.config file and it seems to work !

Thanks again



Well, Aspose.Cells for .NET is created in managed C# which is based on core .NET system classes that also require Full Trust permissions set in certain scenarios. The component needs to access registry settings, system files other than virtual directory for certain operations like parsing fonts etc. So, we always recommend our users to use Aspose.Cells in Full trust permissions set.

Thank you.

Thanks again for your support!



I’m having issue with running aspose.cell 8.5.2 from the .net2.0 folder under Medium Trust.

I’m running on .Net Framework 4.5.1. This is something we have to run under for our development.

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:
[SecurityException: That assembly does not allow partially trusted callers.]
CommandPilot2009.apps.RMIS.ExcelGen.Page_Load(Object sender, EventArgs e) in c:\www\CommandPilot\1.0.1\Inetpub\wwwroot\CommandPilot2009\apps\RMIS\ExcelGen.aspx.cs:175
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +51

I don’t have any issue with reading the license file, but will get the error after the save.
I have tried the following:
WB.Save(this.Response, “RMISExcelDetail.xlsx”, ContentDisposition.Attachment, new OoxmlSaveOptions());

and the following:
MemoryStream ms = new MemoryStream();
ms = WB.SaveToStream();

private void DownloadFile(byte[] dataFile)
HttpContext.Current.Response.AddHeader(“content-disposition”, “attachment; filename=RMISExcelDetail.xlsx”);
HttpContext.Current.Response.ContentType = “application/excel”;
0, dataFile.Length);


Thanks for your posting and considering Aspose.Cells.

It seems your issue is occurring because of partial trust. If you will use Aspose.Cells in full trust, then it should resolve your exception.

Please see this documentation article that talks about partial/full trust issue of Aspose.Cells and should help you in solving this issue.

( http://www.aspose.com/docs/display/cellsnet/Declaration )

I have tried using the example in the link to get it to work under Medium trust but it doesn’t work. When it tries to open the page with the Aspose.Cells reference, it errors out right away and doesn’t even give me the changes to step through. I’m also trying to add the Aspose.Cells.dll to the web.config to grant it full trust like I’m trying with Aspose.PDF.

This is in my page load for the Aspose.Cells
License license = new License();

//Grab Aspose License key path and set the license
String strALP = WebConfigurationManager.AppSettings[“AsposeLicensePath”];
System.IO.Stream stream = System.IO.File.OpenRead(MapPath("~") + @"\Aspose.Total.lic");
catch (Exception ex)
Elmah.ErrorSignal.FromCurrentContext().Raise(new Exception(“Aspose License Issue”, ex));
Debug.WriteLine(“Trouble with License”);

CellsHelper.FontDir = MapPath("~") + @"\Fonts";
// Need the selected risk IDs in a CommaDelimitedStringCollection
// so we can get back our risk items from RiskManager.
CommaDelimitedStringCollection cdscIds = new CommaDelimitedStringCollection();
string items;
if (Request.QueryString[“exportXLS”] != null)
items = Request.QueryString[“exportXLS”].ToString();
if (items.EndsWith(","))
items = items.Substring(0, items.IndexOf(",") - 1);

// codes to create the workbook.

HttpContext.Current.Response.ContentType = “application/excel”;

WB.Save(this.Response, “RMISExcelDetail.xlsx”, ContentDisposition.Attachment, new OoxmlSaveOptions());


Thanks for using Aspose.Cells.

Could you please try putting/installing your Aspose.Cells and Aspose.Pdf assemblies in GAC (Global Assembly Cache). If I am not mistaken, when you will put/install these assemblies in GAC, they will automatically get a full trust permissions and it will fix your issue.

I added the Aspose.Cells and Aspose.PDF to the GAC and still have the same problem.

I’ve attached one of the example that was posted to the forum to try to run it in Medium trust and it failed also.

I also tried the example for Aspose.Cells from GitHub and it also fail to load under Medium Trust.


Thanks for your posting and using Aspose.Cells.

We will look into this issue further and evaluate Aspose.Cells in medium trust level as per instructions and see how it goes and update you asap.

( http://www.aspose.com/docs/display/cellsnet/Declaration )


Thanks for using Aspose.Cells.

I am still working on this issue. So far I have prepared the environment with Windows 7 - 64 bit, IIS, ASP.NET 4.0 and Visual Studio 2013.

Could you please provide me the simple one page web application with few lines of code that runs on Full-Trust and does not run on the Medium-Trust and screenshots to configure them on the IIS and the web.config settings related to Full/Medium Trust levels. These things will help me carry out the investigations further. Thanks for your cooperation.

I have attached the screenshots of my environment for your reference.


Thanks for using Aspose.Cells.

There are two ways to grant full trust to your assembly.

1 - Add assembly in GAC
2 - Inside the Web.config file use a child fullTrustAssemblies configuration section to grant assembly full trust.

Please check these statements from the following article

( https://msdn.microsoft.com/en-us/library/wyts434y.aspx )

Code runs with full trust (code from the GAC always runs in full trust).

Granting ASP.NET Full Trust to Assemblies

The ASP.NET 4 fullTrustAssemblies section enables you to explicitly establish a list of assembly identities that will always be granted full trust. The securityPolicy configuration section in the Web.config file contains a child fullTrustAssemblies configuration section. The FullTrustAssembliesSection section is a standard collection that supports add, remove, and clear operations, where you can specify one or more assembly identities that will be granted full trust at run time. The following example shows to configure ASP.NET full trust assembly in the fullTrustAssemblies configuration section.


Thanks for using Aspose.Cells.

We were able to replicate this issue by running your web application on IIS server. When the following setting in Web.config is used (i.e full trust), it runs fine

but when the following setting is used (i.e medium trust), it throws exception

I have attached the screenshots for a reference.

The code inside your web form is exactly same as mentioned in this article so it should be running fine but unfortunately it is not working.

( http://www.aspose.com/docs/display/cellsnet/Declaration )

We have logged this issue in our database for investigation. We will look into it and fix this issue. Once the issue is resolved or we have some other update for you, we will let you know asap.

This issue has been logged as

  • CELLSNET-43869 - Aspose.Cells is not able to run in the Medium Trust