I receive the following error while trying to create a new Excel object:
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:
System.Security.Permissions.SecurityPermission
Source Error:
Line 26: 'Put user code to initialize the page here Line 27: Line 28: Dim excelDoc As New Aspose.Cells.Excel Line 29: Line 30:
|
Source File:
\\\\WebForm1.aspx.vb
Line: 28
Stack Trace:
[SecurityException: System.Security.Permissions.SecurityPermission] Aspose.Cells.Worksheets.ה(Font ԥ) +0 Aspose.Cells.Worksheets.ד() +22 Aspose.Cells.Worksheets..ctor(ڿ palette) +654 Aspose.Cells.Excel..ctor() +69 WebForm1.Page_Load(Object sender, EventArgs e) in \\\\WebForm1.aspx.vb:28 System.Web.UI.Control.OnLoad(EventArgs e) +67 System.Web.UI.Control.LoadRecursive() +35 System.Web.UI.Page.ProcessRequestMain() +2112 System.Web.UI.Page.ProcessRequest() +218 System.Web.UI.Page.ProcessRequest(HttpContext context) +18 System.Web.CallHandlerExecutionStep.System.Web.HttpApplication+IExecutionStep.Execute() +179 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +87
|
Version Information: Microsoft .NET Framework Version:1.1.4322.2032;
ASP.NET Version:1.1.4322.2032
The web server for the site has a virtual directory that is pointed to a file share on another machine, so all of the site's files are stored on a different machine than the web server. I can fix the problem by adjusting the .Net runtime trust level for the site, but the site is being developed for a government agency with strict security guidelines and the trust level or file permissions cannot be adjusted on the government's servers.
I am also using the Aspose.Words.Document and Aspose.PowerPoint.Presentation objects. I can successfully create a new Document object (using its contructor that takes no arguments). To instantiate a Presentation object (which does not have a constructor that takes no arguments), I must pass in a FileStream object that points to a template file (I get another permissions error if I try to pass in a file path via a string). Since there is only one constructor for the Excel object (which takes no arguments), I cannot use the beforementioned method.
I'm using the newest version of the Cells assembly at the time of this writing (3.8.1.0), and have also duplicated this error by trying to instantiate an Aspose.Excel.Excel object (assembly version 3.6.1.6).
Thanks.
Could you create a new permission set to give Aspose.Cells.dll security permission with "Allow calls to unmanaged assemblies" enabled (SecurityPermission with the UnmanagedCode SecurityPermissionFlag? Aspose.Cells has to call some win32 GDI apis to make some features.
I tried this on my test server setup and it works, but on the production server no Permission Sets or Code Groups are allowed to be created and no changes can be made using the .Net Configuration utility. Thanks.
Please check http://msdn2.microsoft.com/en-US/library/thd4h5h0.aspx
.
I cannot make any changes to the .Net runtime setup. I don’t have access to the machine where the site is hosted, so I can’t run the .Net MMC configuration tool or caspol. The adminstrators of the machine where my site is hosted will not modify the .Net runtime configuration. Is there any way I can avoid this error without changing the .Net runtime setup? Thanks.
Generally I think it's impossible to make Aspose.Cells working without enough security trust.
Another user had met similiar situation and he also found most of his code(not only related to Aspose) cannot run with strict trust level. Finally he set up a stand alone web site to provide web services and his web hosting only reside code to call these web services.