我在我的 SQLCLR 项目中使用线程,当我尝试运行我的用户定义函数时出现以下错误。我可以做些什么来在我的项目中启用并行库和 await/async 等线程?
Msg 6522, Level 16, State 1, Line 4
A .NET Framework error occurred during execution of user-defined routine or aggregate "CalculateInfo":
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: Synchronization, ExternalThreadingSystem.Security.HostProtectionException:
at UserDefinedFunctions.getData()
at UserDefinedFunctions.CalculateInfo()
最佳答案
此错误,如您在其他问题中所述,Deploying SQLCLR project fails when creating assembly in database , 需要满足以下条件:
ALTER ASSEMBLY [AssemblyName]
WITH PERMISSION_SET = UNSAFE;
有关一般使用 SQLCLR 的更多信息,请访问:SQLCLR Info
关于c# - 系统.安全.HostProtectionException : Attempted to perform an operation that was forbidden by the CLR host,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28269682/