sql2005引用c#编写的程序集

来源:互联网 发布:gs域名 编辑:程序博客网 时间:2024/05/22 00:09

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

 

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

禁止的自定义属性

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

复制
System.ContextStaticAttributeSystem.MTAThreadAttributeSystem.Runtime.CompilerServices.MethodImplAttributeSystem.Runtime.CompilerServices.CompilationRelaxationsAttributeSystem.Runtime.Remoting.Contexts.ContextAttributeSystem.Runtime.Remoting.Contexts.SynchronizationAttributeSystem.Runtime.InteropServices.DllImportAttribute System.Security.Permissions.CodeAccessSecurityAttributeSystem.STAThreadAttributeSystem.ThreadStaticAttribute

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

复制
System.Security.SuppressUnmanagedCodeSecurityAttributeSystem.Security.UnverifiableCodeAttribute

禁止的 .NET Framework API

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

复制
eSelfAffectingProcessMgmteSelfAffectingThreadingeSynchronizationeSharedState eExternalProcessMgmteExternalThreadingeSecurityInfrastructureeMayLeakOnAborteUI

支持的 .NET Framework 程序集

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

复制
custommarshallers.dllMicrosoft.visualbasic.dllMicrosoft.visualc.dllmscorlib.dllsystem.data.dllSystem.Data.SqlXml.dllsystem.dllsystem.security.dllsystem.web.services.dllsystem.xml.dllSystem.TransactionsSystem.Data.OracleClientSystem.Configuration

 

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

 

原创粉丝点击