sql2005引用c#编写的程序集

  最近在做一个工具时,想到如果能把自己在vs2010里写的方法放到数据库里,就能更加方便的使用,上网查了一下,sql2005以后的版本是支持clr的,自己做了一个demo也是可以的,但是用到自己的方法时,发现需要用到System.Web.Security ,但是sql2005不支持,sql2005里面支持的程序集是很少的。

 

SQL Server 对程序集中的托管代码有一些限制,以便确保可以以可靠和可伸缩的方式运行它们。这意味着在 SAFE 和 EXTERNAL_ACCESS 程序集不允许可能危及服务器可靠性的某些操作。

禁止的自定义属性

不能用以下自定义属性批注程序集:

System.ContextStaticAttribute
System.MTAThreadAttribute
System.Runtime.CompilerServices.MethodImplAttribute
System.Runtime.CompilerServices.CompilationRelaxationsAttribute
System.Runtime.Remoting.Contexts.ContextAttribute
System.Runtime.Remoting.Contexts.SynchronizationAttribute
System.Runtime.InteropServices.DllImportAttribute 
System.Security.Permissions.CodeAccessSecurityAttribute
System.STAThreadAttribute
System.ThreadStaticAttribute

另外,不能用以下自定义属性批注 SAFE 和 EXTERNAL_ACCESS 程序集:

System.Security.SuppressUnmanagedCodeSecurityAttribute
System.Security.UnverifiableCodeAttribute

禁止的 .NET Framework API

不能从 SAFE 和 EXTERNAL_ACCESS 程序集中调用由禁止的 HostProtectionAttributes 之一批注的任何 Microsoft.NET Framework API。

eSelfAffectingProcessMgmt
eSelfAffectingThreading
eSynchronization
eSharedState 
eExternalProcessMgmt
eExternalThreading
eSecurityInfrastructure
eMayLeakOnAbort
eUI

支持的 .NET Framework 程序集

必须使用 CREATE ASSEMBLY 将自定义程序集引用的任何程序集都加载到 SQL Server 中。下列 .NET  Framework 程序集已经加载到 SQL Server 中,因此,它们可以由自定义程序集引用,而不必使用 CREATE ASSEMBLY。

custommarshallers.dll
Microsoft.visualbasic.dll
Microsoft.visualc.dll
mscorlib.dll
system.data.dll
System.Data.SqlXml.dll
system.dll
system.security.dll
system.web.services.dll
system.xml.dll
System.Transactions
System.Data.OracleClient
System.Configuration

 

所以,大家在用到这样的方法时要注意了,期待sql以后的版本提供更好的支持。

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值