我受到鼓励,了解到Sharepoint 2010客户端对象模型实质上是对服务器的远程调用进行封装。所以,我将Microsoft.Sharepoint.Client.Silverlight.dll和Microsoft.Sharepoint.Client.Silverlight.Runtime.dll从我的Sharepoint 2010服务器复制到我的开发计算机(不带Sharepoint)。我认为我在Sharepoint 2010服务器上测试的Silverlight代码也适用于我的开发机器。当然,我不使用“ApplicationContext.Current.Url”因为我不是在Sharepoint执行,所以我手动添加的SharePoint服务器名称如下(保持匿名的职位):Sharepoint 2010客户端对象模型通过HTTPS进行远程访问
//ClientContext context = new ClientContext(ApplicationContext.Current.Url);
ClientContext context = new ClientContext("https://[servername]");
_web = context.Web;
context.Load(_web);
context.Load(_web.Lists);
context.ExecuteQueryAsync(new ClientRequestSucceededEventHandler (OnRequestSucceeded), new ClientRequestFailedEventHandler(OnRequestFailed));
当我执行代码,我通过Windows身份验证窗口(Sharepoint配置为使用Windows身份验证)提示,我添加了我的域/用户和密码。但是,我收到以下错误:
注意:通过更改绑定安全模式=“传输”并在Sharepoint根目录中包括clientAccessPolicy.xml文件,我可以获得类似的错误网站。我是否需要为客户端对象模型端点配置另一个Sharepoint目录?
- 异常{System.Security.SecurityException ---> System.Security.SecurityException:安全性错误。 at System.Net.Browser.BrowserHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult) at System.Net.Browser.BrowserHttpWebRequest。 <> c__DisplayClass5.b__4(Object sendState) at System.Net.Browser.AsyncHelper。 <> c__DisplayClass2.b__0(Object sendState) --- End of internal exception stack trace --- at System.Net.Browser.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod,Object state) at System.Net.Browser.BrowserHttpWebRequest。 EndGetResponse(IAsyncResult的asyncResult) 在Microsoft.SharePoint.Client.ClientRequest.ExecuteQueryGetResponseAsyncCallback(IAsyncResult的asyncResult)} {System.Exception的} System.Security.SecurityException