System.Security.SecurityException: Request for the permission of type System.Security.Permissions.SecurityPermission failed.
WCF service Pieserver is hosted in IIS 7.5. It is using wshttpbinding.
client : console application.
We are able to add the service reference but get the exception below when we call any methods on the proxy object :
Error Message: System.ServiceModel.FaultException`1[System.ServiceModel.ExceptionDetail]: The type initializer for 'OSIsoft.RtBaseline.DataService.ServerManager' threw an exception.
System.TypeInitializationException: The type initializer for 'OSIsoft.RtBaseline.DataService.ServerManager' threw an exception. ----> System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
at System.Security.Principal.WindowsIdentity.GetCurrent() at OSIsoft.PIInstrumentation.LogWriter.WriteToEventLog(String source, String message, EventLogEntryType elType)
at OSIsoft.PIInstrumentation.LogWriter.WriteGeneralEventLog(String source, String message, Severity svrty, Boolean CheckSuppression) at OSIsoft.PIInstrumentation.RtBLSConfig.get_Setting() at OSIsoft.RtBaseline.DataService.ServerManager..cctor() --- End of inner ExceptionDetail stack trace --- at OSIsoft.RtBaseline.DataService.ServerManager.SetApplicationID(String appID) at PIWebServices.PID...). For more information, see Help and Support Center at https://go.microsoft.com/fwlink/events.asp.
The WCF service application files were hosted on a network share. CAS (Code Access Security) policy has been applied for the service. The PIWebServices.dll is trying to get the current windows identity and failing because the defined CAS policy does not grant ControlPrincipal permissions to it. To provide the permissions on the network share we ran the command below:
CasPol.exe -m -ag 1.2 -url file://\\eas.puget.com/PsePIWebServces/* FullTrust
Reference:
Using CasPol to Fully Trust a Share
https://blogs.msdn.com/b/shawnfa/archive/2004/12/30/344554.aspx https://blogs.msdn.com/b/shawnfa/archive/2004/12/30/344554.aspx
Comments
- Anonymous
December 05, 2010
I would suggest you go post this question on the PI Web Services forum on OSIsoft Virtual Campus (vCampus): http://vCampus.osisoft.com