SQL CLR - 无法从程序集运行SQL CLR

时间:2014-04-02 15:41:33

标签: sql-server sqlclr

我在VS 2013中有一个SQL CLR数据库项目。我正在部署到SQL Server 2008 R2。我已完成以下步骤:

USE master
GO
sp_configure 'clr enabled', 1
GO
RECONFIGURE
GO

USE [MyDb]
GO

ALTER DATABASE [MyDb] SET TRUSTWORTHY ON

use master; 
grant external access assembly to [Domain\MyUser];

use master; 
create master key encryption by password = '*******';

CREATE ASYMMETRIC KEY MyDbExtKey AUTHORIZATION dbo
FROM FILE = 'C:\MyDataKey.snk'
ENCRYPTION BY PASSWORD = '*******';

create login MyDataExtLogin from asymmetric key MyDbExtKey;

GRANT UNSAFE ASSEMBLY to MyDataExtLogin

另外,我已经使用Permission Level“EXTERNAL_ACCESS”&签了名。

当我运行其中一个SQL CLR过程时,我收到以下异常:

An error occurred in the Microsoft .NET Framework while trying to load assembly id 65536. The server may be running out of resources, or the assembly may not be trusted with PERMISSION_SET = EXTERNAL_ACCESS or UNSAFE. Run the query again, or check documentation to see how to solve the assembly trust issues. For more information about this error: 

System.IO.FileLoadException: Could not load file or assembly 'mydata.sqlclr, Version=0.0.0.0, Culture=neutral, PublicKeyToken=151e208e169e0447' or one of its dependencies. The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047)

System.IO.FileLoadException: 
   at System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)

   at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
   at System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
   at System.Reflection.Assembly.Load(String assemblyString)

0 个答案:

没有答案