开发者

Sharepoint COM works from Silverlight but not from WPF

I'm running into an interesting situation. I need to access a SharePoint site asset library from both a WPF application and an Silverlight application. My Silverlight application is working 100%, but my WPF appli开发者_运维知识库cation gets a (500) Internal Server Error back from the service.

Silverlight Code:

    private void Button_Click(object sender, RoutedEventArgs e)
    {
        ClientContext clientContext = new ClientContext("http://myfullyQualifiedName.com");
        clientContext.Load(clientContext.Web);
        clientContext.ExecuteQueryAsync(onQuerySucceeded, onQueryFailed);
    }

    private void onQuerySucceeded(object sender, ClientRequestSucceededEventArgs args)
    {

    }

    private void onQueryFailed(object sender, ClientRequestFailedEventArgs args)
    {

    }

WPF Code:

    private void Button_Click(object sender, RoutedEventArgs e)
    {
        ClientContext clientContext = new ClientContext("http://myfullyqualifiedname.com/");
        //clientContext.Credentials = new NetworkCredential("UserName", "Password", "Domain");
        clientContext.Load(clientContext.Web);
        clientContext.ExecuteQuery();
    }

I have tried with and without specifying credentials, either way I get the Internal server error.

Both Silverlight and non Silverlight Sharepoint client DLL's that I use has is version 14.4762.1000.

Now if I change the URL to one of our other sites, the WPF Code works flawlessly. So I think it must be a SharePoint settings somewhere.


Solved !! Why WPF Authentication wouldn't work when Silverlight works. (WPF was trying to use Kerberos, Silverlight was using NTLM) - Simple fix:

ClientContext _clientContext = new ClientContext(sharePointSiteUrl);
Web _web = _clientContext.Web;

_clientContext.Load(_web, website => website.Title);
_clientContext.Load(_web.Webs);

CredentialCache cc = new CredentialCache();
cc.Add(new Uri(sharePointSiteUrl), "NTLM", CredentialCache.DefaultNetworkCredentials);
_clientContext.Credentials = cc;
_clientContext.AuthenticationMode = ClientAuthenticationMode.Default;

_clientContext.ExecuteQuery();
ListCollection _listCollection = _web.Lists;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜