System.Exception: 试图执行 CLR 主机禁止的操作

消息 6522,级别 16,状态 1,过程 InsertCurrency_String,第 0 行
在执行用户定义例程或聚合 "InsertCurrency_String" 期间出现 .NET Framework 错误:
System.Exception: 试图执行 CLR 主机禁止的操作。
System.Exception:
   在 SqlServerCLRCallNet.CLRFunction.CallSAPFunUpdateDataVB(String strFunName, ListDictionary strArgs, ListDictionary strTableArgs, ListDictionary strRetTabs, ListDictionary& strResult)
   在 SqlServerCLRCallNet.CLRFunction.GetResultSetString(String SNO)

消息 6522,级别 16,状态 1,过程 InsertCurrency_String,第 0 行
在执行用户定义例程或聚合 "InsertCurrency_String" 期间出现 .NET Framework 错误:
System.Security.HostProtectionException: 试图执行 CLR 主机禁止的操作。

受保护的资源(只有完全信任才可访问)是: All     The protected resources (only available with full trust) were: All


要求的资源是: ExternalProcessMgmt          The demanded resources were:

System.Security.HostProtectionException:
   在 VBLib.VBSAP..ctor(String sapSystem, String ApplicationServer, String Client, String SystemNumber)
   在 SqlServerCLRCallNet.CLRGetMara.GetMara(String SNO, String& strMess)

原因:

SQL Server Common Language Integration (CLR) 程式設計不允許使用具有 HostProtectionAttribute (會指定含有 ExternalProcessMgmtExternalThreadingMayLeakOnAbortSecurityInfrastructureSelfAffectingProcessMgmntSelfAffectingThreading SharedStateSynchronizationUI 值的 System.Security.Permissions.HostProtectionResource 列舉) 的類型或成員。下列資料表所列出 Microsoft.VisualBasic.dll 組件的成員和類型之主機保護屬性 (HPA) 值是不允許的。

http://msdn.microsoft.com/zh-tw/library/ms403281(v=SQL.100).aspx

原文地址:https://www.cnblogs.com/Snowfun/p/2683378.html