首页 新闻 赞助 找找看

Silverlight项目中利用Sharepoint客户端对象读取共享文档中Xml对象

0
[待解决问题]

IEnumerable listItems = null; private void GetListItemCollectionFromSP() { string documentListName = "共享文档"; using (ClientOM.ClientContext clientContext = new ClientOM.ClientContext(ClientOM.ApplicationContext.Current.Url)) { // MessageBox.Show(ClientOM.ApplicationContext.Current.Url); ClientOM.Web w = clientContext.Web; clientContext.Load(w); MessageBox.Show(w.Title); clientContext.Load(clientContext.Web.Lists); var documentsList = clientContext.Web.Lists.GetByTitle(documentListName); clientContext.Load(documentsList); ClientOM.CamlQuery camlQuery = new ClientOM.CamlQuery(); camlQuery.ViewXml = @" ConfigXml.xml "; IQueryable myList = documentsList.GetItems(camlQuery); clientContext.LoadQuery(myList); clientContext.ExecuteQueryAsync(new ClientOM.ClientRequestSucceededEventHandler(OnRequestSucceeded), null); } } private void OnRequestSucceeded(Object sender, ClientOM.ClientRequestSucceededEventArgs args) { MessageBox.Show("OK"); Dispatcher.BeginInvoke(new Action(BindData)); MessageBox.Show("OK"); } private void BindData() { ClientOM.ListItem item = (listItems != null && listItems.Count() == 1) ? listItems.First() : null; if (item != null) { using (ClientOM.ClientContext clientContext = new ClientOM.ClientContext(ClientOM.ApplicationContext.Current.Url)) { Microsoft.SharePoint.Client.File.OpenBinaryDirect(clientContext, item["FileRef"].ToString(), new EventHandler(Success), new EventHandler(Faild)); } } } public void Success(object sender, ClientOM.OpenBinarySucceededEventArgs e) { XDocument dom = XDocument.Load(e.Stream); MessageBox.Show(dom.Document.ToString()); //AppConfigXml.Xdom = dom; } public void Faild(object sender, ClientOM.OpenBinaryFailedEventArgs e) { //AppConfigXml.Xdom = null; // MessageBox.Show("靠" + e.Message); }

但是老实弹出这样的问题The property or field has not been initialized. It has not been requested or the request has not been executed. It may need to be explicitly requested 我在Silverlight项目中利用Sharepoint客户端对象模型获取Sharepoint网站列表数据时出现这样的问题

向娟的主页 向娟 | 初学一级 | 园豆:200
提问于:2011-04-19 14:40
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册