【问题标题】:System.ServiceModel.DomainServices.Client.DomainOperationException: Load operation failed for querySystem.ServiceModel.DomainServices.Client.DomainOperationException:查询的加载操作失败
【发布时间】:2014-08-21 22:27:18
【问题描述】:

我在 WCF+Silverlight+RIA 服务应用程序中收到以下错误。它只发生在生产数据库上。

我将生产数据库复制到我的开发机器上,当我从开发环境将 web.config 指向我的生产数据库时出现该错误。如果我指向测试数据库,那么一切正常。

所以我认为数据库中存在一些不匹配问题,所以我尝试比较测试和生产数据库,所有数据库结构都相同。

此错误仅发生在一个函数/查询“GetEventViewAll”上,所有其他操作都在该数据库上运行。所以我认为函数“GetEventViewAll”返回更多行,所以我删除了该表上的所有行,但仍然出现该错误。

此错误仅发生在生产数据库上,而不是生产环境。我正在使用相同的机器,相同的代码,相同的 VS2010。我只是在 web.config 上进行更改以指向其他数据库(生产)然后出错。

谁能告诉我我错过了什么或需要做什么?

VS2010输出窗口的错误是: {System.ServiceModel.DomainServices.Client.DomainOperationException: Load operation failed for query 'GetEventViewAll'. The remote server returned an error: NotFound. ---> System.ServiceModel.CommunicationException: The remote server returned an error: NotFound. ---> System.Net.WebException: The remote server returned an error: NotFound. ---> System.Net.WebException: The remote server returned an error: NotFound. at System.Net.Browser.BrowserHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult) at System.Net.Browser.BrowserHttpWebRequest.<>c__DisplayClassa.b__9(Object sendState) at System.Net.Browser.AsyncHelper.<>c__DisplayClass4.b__1(Object sendState) --- End of inner exception stack trace --- at System.Net.Browser.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod, Object state) at System.Net.Browser.BrowserHttpWebRequest.EndGetResponse(IAsyncResult asyncResult) at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelAsyncRequest.CompleteGetResponse(IAsyncResult result) --- End of inner exception stack trace --- at System.ServiceModel.DomainServices.Client.WebDomainClient1.EndQueryCore(IAsyncResult asyncResult) at System.ServiceModel.DomainServices.Client.DomainClient.EndQuery(IAsyncResult asyncResult) at System.ServiceModel.DomainServices.Client.DomainContext.CompleteLoad(IAsyncResult asyncResult) --- End of inner exception stack trace ---} [System.ServiceModel.DomainServices.Client.DomainOperationException]: {System.ServiceModel.DomainServices.Client.DomainOperationException: Load operation failed for query 'GetEventViewAll'. The remote server returned an error: NotFound. ---> System.ServiceModel.CommunicationException: The remote server returned an error: NotFound. ---> System.Net.WebException: The remote server returned an error: NotFound. ---> System.Net.WebException: The remote server returned an error: NotFound. at System.Net.Browser.BrowserHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult) at System.Net.Browser.BrowserHttpWebRequest.<>c__DisplayClassa.<EndGetResponse>b__9(Object sendState) at System.Net.Browser.AsyncHelper.<>c__DisplayClass4.<BeginOnUI>b__1(Object sendState) --- End of inner exception stack trace --- at System.Net.Browser.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod, Object state) at System.Net.Browser.BrowserHttpWebRequest.EndGetResponse(IAsyncResult asyncResult) at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelAsyncRequest.CompleteGetResponse(IAsyncResult result) --- End of inner exception stack trace --- at System.ServiceModel.DomainServices.Client.WebDomainClient1.EndQueryCore(IAsyncResult asyncResult) at System.ServiceModel.DomainServices.Client.DomainClient.EndQuery(IAsyncResult asyncResult) at System.ServiceModel.DomainServices.Client.DomainContext.CompleteLoad(IAsyncResult asyncResult) --- End of inner exception stack trace ---} Data: {System.Collections.ListDictionaryInternal} InnerException: {System.ServiceModel.CommunicationException: The remote server returned an error: NotFound. ---> System.Net.WebException: The remote server returned an error: NotFound. ---> System.Net.WebException: The remote server returned an error: NotFound. at System.Net.Browser.BrowserHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult) at System.Net.Browser.BrowserHttpWebRequest.<>c__DisplayClassa.b__9(Object sendState) at System.Net.Browser.AsyncHelper.<>c__DisplayClass4.b__1(Object sendState) --- End of inner exception stack trace --- at System.Net.Browser.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod, Object state) at System.Net.Browser.BrowserHttpWebRequest.EndGetResponse(IAsyncResult asyncResult) at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelAsyncRequest.CompleteGetResponse(IAsyncResult result) --- End of inner exception stack trace --- at System.ServiceModel.DomainServices.Client.WebDomainClient`1.EndQueryCore(IAsyncResult asyncResult) at System.ServiceModel.DomainServices.Client.DomainClient.EndQuery(IAsyncResult asyncResult) at System.ServiceModel.DomainServices.Client.DomainContext.CompleteLoad(IAsyncResult asyncResult)} Message: "Load operation failed for query 'GetEventViewAll'. The remote server returned an error: NotFound." StackTrace: null

【问题讨论】:

  • 检查您是否可以访问 prod DB 服务器
  • @K.B 我确实备份了 prod 数据库并在我的开发 PC 中恢复。当我连接恢复的 DB(prod DB) 时,我只在特定功能上收到该错误,其他操作工作正常。
  • 您是否对数据库架构进行了任何更改
  • @K.B 是的,我做了一些改变,我也在 prod DB 中做了同样的事情。我使用 dbdiff 工具比较了两个结构相同的数据库。
  • @K.B 感谢 KB,我找到了解决方案。

标签: c# .net wcf silverlight ria


【解决方案1】:

通过在函数中添加 Query-HasSideEffects 属性解决。

[Query(HasSideEffects = true)]    //<--- this line solved the problem
public IQueryable<EventView> GetEventView(List<string> siteName)
{
 .....
}

我向该函数传递了一个列表。该列表是从表格中填写的。测试数据库的值较少,生产数据库的值更多,生产数据库中的列表计数更多。所以我得到了以下错误

The Maximum URI length of 2083 was exceeded

所以我把 Query 属性放到那个函数来解析!

【讨论】:

  • (在 Silverlight 中)如果添加属性 [Query(HasSideEffects = true)]。添加 .Where() 或 .OrderBy() 时,查询加载失败。你解决了吗?示例:_domainServiceAtClient.Load(query.Where(p=>p.ID = _id))。
  • 更新:部署web时出错。
猜你喜欢
  • 1970-01-01
  • 2013-01-13
  • 2023-04-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-12-26
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多