SharePoint 2010:ADO.NET/WCF 数据服务 (listdata.svc) 异常"Object reference not set to an instance of an obj



我正在尝试使用 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

有人对如何解决这个问题有好主意吗?

期待得到一个解决方案;-)

马赛尔

首先在 14 配置单元中查找事件日志和 SharePoint 日志。 302 HTTP状态代码是"找到",而不是错误,我怀疑您的问题与安全性有关。 在您发布的代码中,没有指定域。

相关内容

最新更新