2013-01-07 84 views
1

我有一個使用XRM SDK查詢CRM的網站。大多數情況下,我使用的是查詢表達式,但是我在一個頁面上進行聚合計數,因此我正在使用Fetch XML查詢。我已經在我的本地開發人員機器上調試了該網站,指向Dev CRM服務器沒有任何問題。但是,如果我更新我的配置並指向我們的QA CRM,則會出現通用SQL錯誤。我打開與診斷工具跟蹤,這是我看到試圖執行由獲取XML生成的SQL時出現錯誤:嘗試執行FetchXml查詢時出現「通用SQL錯誤」

An error occurred in the Microsoft .NET Framework while trying to load assembly id 65536. 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 'microsoft.crm.sqlclr.helper, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' 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) 

    at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) 
    at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning() 
    at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) 
    at System.Data.SqlClient.SqlDataReader.ConsumeMetaData() 
    at System.Data.SqlClient.SqlDataReader.get_MetaData() 
    at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) 
    at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) 
    at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) 
    at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method) 
    at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method) 
    at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior) 
    at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader() 
    at Microsoft.Crm.CrmDbConnection.InternalExecuteWithRetry[TResult](Func`1 ExecuteMethod, IDbCommand command) 
    at Microsoft.Crm.CrmDbConnection.InternalExecuteReader(IDbCommand command, Boolean capturePerfTrace) 
    at Microsoft.Crm.CrmDbConnection.ExecuteReader(IDbCommand command, Boolean impersonate, Boolean capturePerfTrace) 
    at Microsoft.Crm.BusinessEntities.BusinessProcessObject.ExecuteQuery(CrmDbConnection dbConnection, IDbCommand command, ISqlExecutionContext context, Nullable`1 commandTimeout) 

我做了一些研究,我能找到的最好的事情是this KB article。但它是用於SQL Server 2005,CRM是SQL Server 2008.有誰知道如何解決這個問題?

+0

什麼查詢你想運行?您是否在數據庫中的qa機器上檢查用戶權限?也許證書問題? –

+0

@GregOks這是一個左外連接的兩個表上的聚合查詢...你建議我檢查什麼用戶權限? – Daryl

回答

1

它看起來像是質量保證數據庫的權限問題。見http://social.msdn.microsoft.com/Forums/en/sqlnetfx/thread/2465ac11-735c-4362-8da4-1ed672b0e261http://crmpt.blogspot.de/2011/12/charts-aggregated-by-date-problem.html參考

開始與以下設置爲您的組織的數據庫

ALTER DATABASE FOOBAR_MSCRM SET trustworthy ON 

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

+0

我們還必須更換所有者,但確實解決了問題。謝謝! – Daryl

相關問題