sql-server - MSSQL加载程序集错误

标签 sql-server .net-assembly

我在运行使用 MSSSQL 中的程序集的函数时收到以下错误:

Msg 10314, Level 16, State 11, Line 36 An error occurred in the Microsoft .NET Framework while trying to load assembly id 65800. 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 'exporttoexcel, Version=0.76.0.0, Culture=neutral, PublicKeyToken=f73371c9a1809a3f' or one of its dependencies. Exception from HRESULT: 0x80FC80F1 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)

但是在我重新创建函数和程序集之后,在一段时间内一切正常:

DROP FUNCTION [dbo].[fnExportToExcel]
DROP ASSEMBLY ExcelExporter

CREATE ASSEMBLY ExcelExporter  
AUTHORIZATION [DOMAIN\ACCOUNT]
FROM 'ExportToExcel.dll'
WITH PERMISSION_SET = UNSAFE

CREATE FUNCTION [dbo].[fnExportToExcel](@Query [nvarchar](max), @FilePath [nvarchar](max), @FileName [nvarchar](max), @SheetNames [nvarchar](max))
RETURNS [nvarchar](max) WITH EXECUTE AS CALLER
AS 
EXTERNAL NAME ExcelExporter.[ExportToExcel_DLL.cls_ExcelExport].[ExportToExcel]
GO

有什么想法可能导致 MSSQL 丢失程序集引用吗?

最佳答案

我使用了 Alex K 提供的链接。 Link

就我而言,运行此命令解决了问题:

EXEC sp_changedbowner 'sa' 

关于sql-server - MSSQL加载程序集错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43099202/

相关文章:

bytecode - 为什么这个修改后的程序集不能运行? (JIT 编译器遇到内部限制。)

sql-server - 是否可以从表的列中删除非聚集索引?

sql-server - 在 Sql Server 中存储 UInt32 的最佳方法

c# - 性能: Lots of queries or lots of processing?

.net - "Why is my .net exe so huge"分析工具?

C# 找不到类型或命名空间名称

.net - "Could not load file or assembly"使用团队城市构建时

sql-server - SQL Server 如何知道对金钱使用什么精度

sql-server - 连字符与破折号 : Replace Dash with Hyphen

c# - 如何使动态加载的程序集中的设置提供程序可用于反射?