0

我有以下错误消息:

Msg 10314, Level 16, State 11, Line 1
An error occurred in the Microsoft .NET Framework while trying to load assembly id 66007. 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 'powerstatregression, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' 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)

我运行此代码,最后几行导致问题:

ALTER DATABASE dasolPSDev SET TRUSTWORTHY ON;
GO

CREATE ASSEMBLY PowerStatRegression
AUTHORIZATION [dbo]
from 'C:\SqlDlls\PowerStatRegression.dll'
WITH PERMISSION_SET = UNSAFE
GO

CREATE PROCEDURE [dbo].[SpCreatePowerStatCorr]
    @strUID [nvarchar](4000),
    @seqId [int],
    @flagProgress [int]
WITH EXECUTE AS CALLER
AS
EXTERNAL NAME [PowerStatRegression].[StoredProcedures].[SpCreatePowerStatCorr]
GO

CREATE PROCEDURE [dbo].[SpCreatePowerStatCorrEx]
    @strUID [nvarchar](4000),
    @seqId [int],
    @flagProgress [int]
WITH EXECUTE AS CALLER
AS
EXTERNAL NAME [PowerStatRegression].[StoredProcedures].[SpCreatePowerStatCorrEx]
GO


CREATE PROCEDURE [dbo].SpCheckCollinearity
    @strUID [nvarchar](4000),
    @seqId [int],
    @flagProgress [int]
WITH EXECUTE AS CALLER
AS
EXTERNAL NAME [PowerStatRegression].[StoredProcedures].[SpCheckCollinearity]
GO


CREATE PROCEDURE [dbo].[AboutPowerStatCorrelation]
WITH EXECUTE AS CALLER
AS
EXTERNAL NAME [PowerStatRegression].[StoredProcedures].[AboutPowerStatCorrelation]
GO

--  To Test
dbo.AboutPowerStatCorrelation
GO

grant execute on SpCreatePowerStatCorr to db_executor
GO
4

2 回答 2

0

@chris 您在项目中引用了哪些其他程序集?在您的自定义程序集之前,您可能需要将一些其他程序集添加到 sql server,这就是导致该错误的原因。例如,如果您引用 Newtonsoft 之类的东西进行 JSON 解析,则需要在您的之前添加该程序集。

于 2012-08-15T22:07:04.080 回答
0

当我试图加载一个针对 x86(32 位)构建的 dll 时,我刚刚遇到了这个错误——或者至少是一个非常相似的错误,但是 Sql Server 是 x64。该错误仅在尝试运行我注册的功能时显示......注册时它没有抱怨!

将构建更改为针对“任何 CPU”并重新注册程序集对我有用。

于 2013-10-07T11:26:15.943 回答