我写了一个用户定义函数,获取一个UtcTimeStamp和windowstimezoneid作为参数和返回的时间戳的时区。
I wrote a User Defined Function that gets a UtcTimeStamp and a windowstimezoneid as parameters and returns the TimeStamp for the TimeZone.
但是,如果我想执行它在一个简单的选择,我得到了以下错误:
But if i want to execute it in a simple select i get the following error:
A .NET Framework error occurred during execution of user-defined routine or aggregate "ToLocalTime":
System.Security.HostProtectionException: Attempted to perform an operation that was forbidden by the CLR host.
The protected resources (only available with full trust) were: All
The demanded resources were: MayLeakOnAbort
System.Security.HostProtectionException:
bei TimeFunctions.ToLocalTime(DateTime UtcTimestamp, String WindowsTimeZoneId)
我执行选择的SA。我一系列的CLR启用1.我使用SQL Server 2008 R2(10.50.1600)。
I execute the select as sa. I set clr enabled to 1. I use SQL Server 2008 R2 (10.50.1600).
有谁知道我必须设置为得到这个工作,或者我可能做错了?
Does anyone know what i have to set to get this working or what i may done wrong?
CLR组件具有信任级别。
这其中需要,因为使用MayLeakOnAbort所需的权限不安全权限
This one requires UNSAFE permissions because of the rights required to use "MayLeakOnAbort"
要么改变CLR的东西更安全,或者不安全的权利重新添加该组件。单词不安全正是如此,当然...
Either change the CLR to something safer, or re-add the assembly with UNSAFE rights. The word "UNSAFE" is exactly that of course...