.net – 在SQL Server上执行用户定义函数时出现System.Security.
发布时间:2020-12-12 07:48:12 所属栏目:MsSql教程 来源:网络整理
导读:我编写了一个用户定义函数,它获取UtcTimeStamp和 windowstimezoneid作为参数,并返回TimeZone的TimeStamp. 但如果我想在一个简单的选择中执行它我得到以下错误: A .NET Framework error occurred during execution of user-defined routine or aggregate "ToL
我编写了一个用户定义函数,它获取UtcTimeStamp和
windowstimezoneid作为参数,并返回TimeZone的TimeStamp.
但如果我想在一个简单的选择中执行它我得到以下错误: 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) 我执行select as sa.我将clr设置为1.我使用SQL Server 2008 R2(10.50.1600). 有谁知道我必须设置什么才能使这个工作或我可能做错了什么? 解决方法CLR程序集有 trust levels.这个需要UNSAFE权限,因为使用“MayLeakOnAbort”所需的权利 将CLR更改为更安全的内容,或者使用UNSAFE权限重新添加程序集. “UNSAFE”这个词当然是…… (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |