When trying to execute a stored procedure that load a CLR assembly, the following error may appear:

EXEC sp_my_procedure

 Msg 10314, Level 16, State 11, Line 1

An error occurred in the Microsoft .NET Framework while trying to load assembly id 65543. 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 'assembly_name, Version=1.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.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)

 

 Solution:

 

Use the sp_changedbowner stored procedure to change the database owner to sa:

USE DATABASE_NAME
GO
EXEC sp_changedbowner 'sa'

 

OR:


Then, you need to alter the database by setting the TRUSTWORTHY database property to ON:

ALTER DATABASE DATABASE_NAME
SET TRUSTWORTHY ON;
GO

 

For more information regarding the TRUSTWORTHY Database Property you can access this link:

http://technet.microsoft.com/en-us/library/ms187861.aspx

 


No feedback yet