Sharepoint 2010:ADO.NET/WCF 数据服务 (listdata.svc) 异常“对象引用未设置到对象的实例”

发布于 2024-11-07 08:40:48 字数 836 浏览 3 评论 0原文

我正在尝试使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

入画浅相思 2024-11-14 08:40:48

首先查看事件日志和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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文