Aspese.Cell

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

Stefano

Hi,


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!

Regards

Stefano

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());
Response.End();

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

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


Hi,

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.

( Declaration|Documentation )

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();

try
{
//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”);
license.SetLicense(stream);
stream.Close();
}
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);
cdscIds.AddRange(items.Split(‘,’));
}

// codes to create the workbook.

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

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


Hi,

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.

Hi,

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.

( Declaration|Documentation )

Hi,

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.

Hi,

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.

Hi,

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

Hi,


We have evaluated your issue “CELLSNET-43869” further.
We actually removed the codes “[assembly: AllowPartiallyTrustedCallers]” in order to pass APTCA check of Binscope. We will add “[assembly: AllowPartiallyTrustedCallers]” back in order to make Aspose.Cells run in the Medium Trust environment.

Once the fix is available, we will let you know here.


Thank you.

Thank you for the information. Hopefully we’ll hear back from you guys soon with a fix.

Hi,

Thanks for your using Aspose.Cells.

Please download and try the latest fix: Aspose.Cells for .NET v8.5.2.4 and let us know your feedback.

Thank you for getting back on the fix. I was able to use the latest version under medium trust. I updated the reference to Aspose.Cells and was able to generate the Excel report without having to make any code changes.


Thank you again.

Hi,

Thanks for sharing good news with us and using Aspose.Cells.

We are pleased to know that your issue is finally resolved with the latest fix. Let us know if you encounter any other issue, we will be glad to look into it and help you further.

The issues you have found earlier (filed as CELLSNET-43869) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.