2008-09-16 41 views
33

嘗試運行CLR存儲過程時收到以下錯誤。任何幫助深表感謝。運行CLR存儲過程的FileLoadException/Msg 10314錯誤

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) 

回答

0

貴裝配做文件I/O?如果是這樣,您必須授予程序集執行此操作的權限。在SSMS:

  1. 展開 「數據庫」
  2. 展開節點數據庫
  3. 展開 「可編程」
  4. 展開 「組件」
  5. 右鍵單擊您的裝配,選擇屬性
  6. 在「常規」頁面上,將「權限設置」更改爲「外部訪問」
67

Ran the下面的SQL命令和問題似乎已解決。

USE database_name 
GO 

EXEC sp_changedbowner 'sa' 
ALTER DATABASE database_name SET TRUSTWORTHY ON 
+1

你的意思是USE數據庫名稱 – 2009-11-21 23:17:25

8

使用任意CPU配置構建您的項目。當我使用x86配置編譯我自己的項目並試圖在x64 SQL服務器上運行它時,我遇到了這個問題。

0
ALTER AUTHORIZATION ON DATABASE::mydb TO sa; 
ALTER DATABASE [myDB] SET TRUSTWORTHY ON 
GO