====== Code element in SSRS ====== SSRS's ''Code'' element supports the embedding of user-defined functions in reports. You may find when you first attempt to preview reports containing ''Code'' elements that you receive an error like "Request for the permission of type..." -- specifying whichever type you have referenced in your element. e.g. ''System.Security.Permissions.SecurityPermission'' when [[https://blogs.msdn.microsoft.com/floditt/2009/08/10/request-for-the-permission-of-type-securitypermission-failed/|trying to call]] ''System.Security.Principal.WindowsIdentity.GetCurrent()''. This is due to SSRS's [[https://msdn.microsoft.com/en-us/library/ms154658.aspx|Code Access Security]] feature and will require some config changes in [[https://social.msdn.microsoft.com/Forums/sqlserver/en-US/9af8f39a-9dc5-49ab-91af-2f64198c8477/ssrs-2008-custom-code-for-database-query?forum=sqlreportingservices|a number of places]]. The location of the relevant [[https://msdn.microsoft.com/en-us/library/ms155866.aspx|config files]] may depend on your SQL version. ===== Visual Studio ===== If you're simply previewing in Visual Studio the relevant config file is ''RSPreviewPolicy.config''. In my defaujlt setup I found that the Report_Expressions_Default_Permissions CodeGroup was allocated PermissionSet ''Execution'' which isn’t enough – to allow report preview I changed it to ''FullTrust''. {{tag> ssrs admin}}