Sharepoint 2010:ADO.NET/WCF 数据服务 (listdata.svc) 异常“对象引用未设置到对象的实例”
我正在尝试使用 ADO.NET/WCF 数据服务 = listdata.svc 从 Sharepoint 2010 获取一些列表信息。
当我使用浏览器尝试此操作时,它工作正常 - 只要我已经登录到 Sharepoint 站点。
但是,当我尝试以编程方式访问相同的 URL(使用测试控制台应用程序)时,它不起作用。使用 Fiddler,我发现收到 302 错误,指出“对象引用未设置到对象的实例”。
这是我的测试代码:
Sub Main()
Console.WriteLine("Starting...")
Dim dc As New MyDataContext(
New Uri("http://myurl/mysite/_vti_bin/listdata.svc/"))
dc.Credentials = New NetworkCredential("[[MyUserName]]",
"[[Password]]")
Dim results = From x In dc.Tasks
Select x
For Each item In results
Console.WriteLine(item.Title)
Next
Console.WriteLine("Finished. Press any key to exit the application.")
Console.ReadKey()
End Sub
有人对如何解决这个问题有好主意吗?
期待找到解决方案;-)
Marcel
I am trying to get some list information from a Sharepoint 2010 using the ADO.NET/WCF Data Services = listdata.svc.
It works fine when I am trying this with the browser - as long as I am already logged into the Sharepoint site.
But when I try to access the same URL programmatically (using a test console application), it does not work. Using Fiddler, I see that I get a 302 error that says "Object reference not set to an instance of an object".
Here is my test code:
Sub Main()
Console.WriteLine("Starting...")
Dim dc As New MyDataContext(
New Uri("http://myurl/mysite/_vti_bin/listdata.svc/"))
dc.Credentials = New NetworkCredential("[[MyUserName]]",
"[[Password]]")
Dim results = From x In dc.Tasks
Select x
For Each item In results
Console.WriteLine(item.Title)
Next
Console.WriteLine("Finished. Press any key to exit the application.")
Console.ReadKey()
End Sub
Does anybody have a good idea on how to fix this problem?
Looking forward to get a solution ;-)
Marcel
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先查看事件日志和sharepoint 登录 14-hive。 302 HTTP 状态代码是“找到”,而不是错误,我怀疑您的问题与安全有关。在您发布的代码中没有指定域。
start by looking in both the event logs & sharepoint logs in the 14-hive. the 302 HTTP status code is 'found', not error, i suspect your problem is related to security. in the code you posted there is no domain specified.