36

尝试运行 CLR 存储过程时收到以下错误。任何帮助深表感谢。

Msg 10314, Level 16, State 11, Line 1
An error occurred in the Microsoft .NET Framework while trying to load assembly id 65752. 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 'orders, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An error relating to security occurred. (Exception from HRESULT: 0x8013150A)
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.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)
4

5 回答 5

69

Ran the SQL commands below and the issue appears to be resolved.

USE database_name
GO

EXEC sp_changedbowner 'sa'
ALTER DATABASE database_name SET TRUSTWORTHY ON 
于 2008-09-16T13:52:55.010 回答
8

使用任何 CPU 配置构建您的项目。当我使用 x86 配置编译我自己的项目并尝试在 x64 SQL 服务器上运行它时,我遇到了这个问题。

于 2011-08-31T09:00:34.470 回答
2

应用了上述所有建议,但失败了。然后我用“Any CPU”选项重新编译了我的源代码,它成功了!

此链接有帮助: SQL Server failed to load assembly with PERMISSION

于 2012-05-01T10:12:27.277 回答
0

Does your assembly do file I/O? If so, you must grant the assembly permission to do this. In SSMS:

  1. Expand "Databases"
  2. Expand the node for your database
  3. Expand "Programmability"
  4. Expand "Assemblies"
  5. Right-click your assembly, choose Properties
  6. On the "General" page, change "Permission set" to "External access"
于 2008-09-16T13:51:56.887 回答
-1
ALTER AUTHORIZATION ON DATABASE::mydb TO sa;
ALTER DATABASE [myDB] SET TRUSTWORTHY ON
GO
于 2014-09-15T12:31:41.753 回答