Astoria 错误 - 需要一个绝对的、格式良好的 http URL,没有查询或片段
我第一次通过使用实体框架创建模型来尝试我的 ADO.NET 数据服务。我正在通过创建一个简单的控制台应用程序来测试该服务是否通过客户端运行。这是我的 Main 方法的主体:
MyEntities context = new MyEntities (new Uri("MyEntitiesDataService.svc", UriKind.Relative));
var query = (from c in context.EmployeeSet select c);
foreach (Employee emp in query)
{
Console.WriteLine("{0}", emp.FirstName);
}
当我到达声明“上下文”的第一行时,我的调试器跳转到 Reference.cs 文件,其中同一项目中的服务引用显示为“”。
/// <summary>
/// Initialize a new MyEntities object.
/// </summary>
public MyEntities(global::System.Uri serviceRoot) :
base(serviceRoot)
谁能看到我做错了什么吗?或者您建议我做什么来通过控制台应用程序由服务呈现?下一步将是 Silverlight 3.0。
I'm trying out my ADO.NET Data Service for the first time by having the model create using Entity Framework. I am testing to see if the service works via a client by creating a simple console application. Here is the body of my Main method:
MyEntities context = new MyEntities (new Uri("MyEntitiesDataService.svc", UriKind.Relative));
var query = (from c in context.EmployeeSet select c);
foreach (Employee emp in query)
{
Console.WriteLine("{0}", emp.FirstName);
}
When I reach the first line where the "context" is declared, my debugger jumps to the Reference.cs file where I have the Service Reference within the same project saying "".
/// <summary>
/// Initialize a new MyEntities object.
/// </summary>
public MyEntities(global::System.Uri serviceRoot) :
base(serviceRoot)
Can anyone see what I'm doing wrong? Or what do you suggest I do to render by services via a console application? Next step will be Silverlight 3.0.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您传递给 URI 构造函数的 URI 字符串不是相对路径。
相对路径以“/”字符开头。要使此代码正常工作,请将 URI 构造函数的第二个参数更改为 UriKind.RelativeOrAbsolute。
希望这有帮助
The URI string you are passing in to the URI constructor is not a relative path.
Relative Paths start with a '/' character. To get this code to work , change the second parameter of the URI constructor to UriKind.RelativeOrAbsolute .
Hope this helps