Groups | Blog | Home
all groups > sql server reporting services > september 2005 >

sql server reporting services : Reporting Service Custom Code Error - Request for the permission of type


jonknutsonhome NO[at]SPAM yahoo.com
9/7/2005 1:31:35 PM
I have added some Custom Code in Reporting Service.
Reports - Report Properties - Code Tab - Custom Code

Here is my code.

public Function Please(d as DateTime, CultureFormat as String) as
String

dim returnvalue as String
Try
System.Threading.Thread.CurrentThread.CurrentCulture = new
System.Globalization.CultureInfo(CultureFormat)
dim ci as System.Globalization.CultureInfo
ci = new System.Globalization.CultureInfo(CultureFormat)

returnvalue = d.ToString("D",ci)

Catch ex As Exception
returnvalue = ex.ToString()
End Try

Return returnvalue
End Function



If I preview this report it works fine, but when I deploy this report,
I get this error message.


System.Security.SecurityException: Request for the permission of type
System.Security.Permissions.SecurityPermission, mscorlib,
Version=1.0.5000.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089 failed.

at
System.Security.CodeAccessSecurityEngine.CheckTokenBasedSetHelper(Boolean
ignoreGrants,
TokenBasedSet grants, TokenBasedSet denied, TokenBasedSet demands)

at
System.Security.CodeAccessSecurityEngine.CheckSetHelper(PermissionSet
grants, PermissionSet
denied, PermissionSet demands)

at System.Threading.Thread.set_CurrentCulture(CultureInfo value)

at CustomCodeProxy.Please(DateTime d, String CultureFormat)

Has anyone run into this before?

Thanks, Jon
Daniel Reib [MSFT]
9/7/2005 5:22:43 PM
The code security permission do not allow you to set the current threads
culture. Since you are passing the culture info into the ToString method
you should not need to do this so I would just remove this line of code:

System.Threading.Thread.CurrentThread.CurrentCulture = new
System.Globalization.CultureInfo(CultureFormat)

--
-Daniel
This posting is provided "AS IS" with no warranties, and confers no rights.


[quoted text, click to view]

AddThis Social Bookmark Button