You deployed your website using IIS on Windows 2008. While trying to access the site the following error message is shown-
System.servicemodel.FaultException [System.servicemodel.ExceptionDetail]: The type initializer for ‘BallycashRedemption sevice.Cashredemptionservice’ threw an exception. (Fault details is equal to an exception details, likely created by IncludeExceptionDetailInFaults=True, whose valus is : System.TypeInitializationException: The type initializer for ‘BallyCashRedemptionService.CashRedemptionService’ threw an exception.—- System.Security.securityException: Request for the permission of type ‘System.Security.Permissions.FileIOPermission, mscorlib,version=18.104.22.168, culture=netural, publicKeyToken=b77a5c561934e089’failed. At system.security.codeAccessSecurityEngine.check (Object demand,stackcrawlmark&))
The website works fine in your local setup. There are multiple reasons for this error.
1. It could be caused by Trust level set fro your web application. Most of the webhost provide Medium trust level for the ASP .Net applications. Such websites will not have access to registry, no access to event viewer or reflection permissions. You can add or request to add the below tag in web.config under system.web –
<trust level=”Full” />
2. If it still doesn’t work or trust level is already provided as FULL then try changing the identity of the application pool under which your website is deployed. For example – If the website is deployed under DefaultAppPool then change the identity to ‘LocalService’ or ‘LocalSystem’.