Click here to Skip to main content
15,885,742 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
when i run(load) ".aspx" page that contain crystal report viewer on web server it gives this error. how can i solve it? Please Help...

What I have tried:

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.FileIOPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

Source Error:


Line 17: {
Line 18: ReportDocument crystalReport = new ReportDocument();
Line 19: crystalReport.Load(Server.MapPath("~/CrystalReport1.rpt"));
Line 20: DataSet1 dsCustomers = GetData("select * from tblorderdetails");
Line 21: crystalReport.SetDataSource(dsCustomers);
Posted
Updated 7-Jul-16 1:25am

Read the error message:
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.

The do exactly what it says: your web page app is trying to perform an IO operation that needs it to have specific permissions. Only your admin can change the permissions your app runs under, or the permissions on the folder or file it is trying to access.
 
Share this answer
 
As stated by OriginalGriff, its a access permission issue, add below tag in web.config
XML
<system.web>
<trust level="Full"/>
</system.web>

Hope it helps
 
Share this answer
 
Comments
Dipal10 7-Jul-16 7:33am    
After Adding <trust level="Full"/> in web.config I got this error

Configuration Error

Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

Parser Error Message: This configuration section cannot be used at this path. This happens when the site administrator has locked access to this section using <location allowoverride="false"> from an inherited configuration file.

Source Error:


An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.
koolprasad2003 7-Jul-16 7:42am    
Where you have added it ? check the machine.config to see if something there is blocking you ?
check out below link
https://support.microsoft.com/en-in/kb/917413
Dipal10 7-Jul-16 8:34am    
My Project is deploy in web server so how can i access machine.config file for web server?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900