WCF DataServices Astoria Version 2 not returning results when called from Code
I have WCF DataService which works great when queried via directly through the browser. However, when run from Visual Studio 2010 where I'm trying to query and bind to a grid, it throws a DataServiceQueryException telling me "Resource Not Found" a 404 error. This is reall开发者_Go百科y bizarre. Any thoughts?
Are you self hosting the service? When you test the service are you running it in the VS dev server?
My though is that the service may not actually be running when you try to add service reference.
This is still having issues. The service is hosted in the client. Here is the full error:
[DataServiceClientException: The resource cannot be found. 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: gray;} .error {margin-bottom: 10px;} .expandable { text-decoration:underline; font-weight:bold; color:navy; cursor:hand; }
<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. 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> Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1
</font>
</body>
] System.Data.Services.Client.QueryResult.Execute() +475306 System.Data.Services.Client.DataServiceRequest.Execute(DataServiceContext context, QueryComponents queryComponents) +137
[DataServiceQueryException: An error occurred while processing this request.]
System.Data.Services.Client.DataServiceRequest.Execute(DataServiceContext context, QueryComponents queryComponents) +396
System.Data.Services.Client.DataServiceQuery1.Execute() +77
System.Data.Services.Client.DataServiceQuery
1.GetEnumerator() +13
System.Collections.Generic.List1..ctor(IEnumerable
1 collection) +315
System.Linq.Enumerable.ToList(IEnumerable`1 source) +58
TripReport.Controllers.GeneralControllers.GetDirectorates() in C:\Users\administrator\Documents\Visual Studio 2010\Projects\TripReport\Common\Controllers\GeneralControllers.cs:14
TripReport.Controls.CreateTrip.Page_Load(Object sender, EventArgs e) in C:\Users\administrator\Documents\Visual Studio 2010\Projects\TripReport\Controls\CreateTrip.ascx.cs: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
精彩评论