从Code调用时,WCF DataServices Astoria版本2不返回结果

时间:2010-12-07 08:38:03

标签: c# wcf wcf-data-services

我有WCF DataService,通过浏览器直接查询时效果很好。但是,当从我试图查询并绑定到网格的Visual Studio 2010运行时,它会抛出一个DataServiceQueryException告诉我“找不到资源”404错误。这真是奇怪。有什么想法吗?

2 个答案:

答案 0 :(得分:0)

您是自托管服务吗?当您测试服务时,您是否在VS dev服务器中运行它?

我尝试添加服务引用时可能实际上并未运行该服务。

答案 1 :(得分:0)

这仍有问题。该服务托管在客户端中。这是完整的错误:

[DataServiceClientException:              无法找到该资源。                   body {font-family:“Verdana”; font-weight:normal; font-size:.7em; color:black;}          p {font-family:“Verdana”; font-weight:normal; color:black; margin-top:-5px}          b {font-family:“Verdana”; font-weight:bold; color:black; margin-top:-5px}          H1 {font-family:“Verdana”; font-weight:normal; font-size:18pt; color:red}          H2 {font-family:“Verdana”; font-weight:normal; font-size:14pt; color:maroon}          pre {font-family:“Lucida Console”; font-size:.9em}          .marker {font-weight:bold; color:black; text-decoration:none;}          .version {color:grey;}          .error {margin-bottom:10px;}          .expandable {text-decoration:underline;字体重量:粗体;颜色:海军;光标:手; }              

<body bgcolor="white">

        <span><H1>Server Error in '/' Application.<hr width=100% size=1 color=silver></H1>

        <h2> <i>The resource cannot be found.</i> </h2></span>

        <font face="Arial, Helvetica, Geneva, SunSans-Regular, sans-serif ">

        <b> Description: </b>HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. &nbsp;Please review the following URL and make sure that it is spelled correctly.
        <br><br>

        <b> Requested URL: </b>/TripReport.svc/OPRs<br><br>

        <hr width=100% size=1 color=silver>

        <b>Version Information:</b>&nbsp;Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1

        </font>

</body>

]    System.Data.Services.Client.QueryResult.Execute()+ 475756    System.Data.Services.Client.DataServiceRequest.Execute(DataServiceContext context,QueryComponents queryComponents)+137

[DataServiceQueryException:处理此请求时发生错误。]    System.Data.Services.Client.DataServiceRequest.Execute(DataServiceContext context,QueryComponents queryComponents)+396    System.Data.Services.Client.DataServiceQuery 1.Execute() +77 System.Data.Services.Client.DataServiceQuery 1.GetEnumerator()+13    System.Collections.Generic.List 1..ctor(IEnumerable 1个集合)+315    System.Linq.Enumerable.ToList(IEnumerable`1 source)+58    C:\ Users \ administrator \ Documents \ Visual Studio 2010 \ Projects \ TripReport \ Common \ Controllers \ GeneralControllers.cs中的TripReport.Controllers.GeneralControllers.GetDirectorates():14    C:\ Users \ administrator \ Documents \ Visual Studio 2010 \ Projects \ TripReport \ Controls \ CreateTrip.ascx.cs中的TripReport.Controls.CreateTrip.Page_Load(Object sender,EventArgs e):16    System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp,Object o,Object t,EventArgs e)+14    System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender,EventArgs e)+35    System.Web.UI.Control.OnLoad(EventArgs e)+91    System.Web.UI.Control.LoadRecursive()+ 74    System.Web.UI.Control.LoadRecursive()+ 146    System.Web.UI.Control.LoadRecursive()+ 146    System.Web.UI.Control.LoadRecursive()+ 146    System.Web.UI.Control.LoadRecursive()+ 146    System.Web.UI.Control.LoadRecursive()+ 146    System.Web.UI.Control.LoadRecursive()+ 146    System.Web.UI.Control.LoadRecursive()+ 146    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint,Boolean includeStagesAfterAsyncPoint)+2207