I'm trying to read the contents of Sharepoint List 'pfa' using Silverlight 5 and the following VB code. I am geting diagnostic pop-up windows 1-5 but then that's it and nothing further happens. Sharepoint Foundation is running on the local machine.

Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Net
Imports System.Windows
Imports System.Windows.Controls
Imports System.Windows.Documents
Imports System.Windows.Input
Imports System.Windows.Media
Imports System.Windows.Media.Animation
Imports System.Windows.Shapes
Imports sp = Microsoft.SharePoint.Client

Partial Public Class MainPage
Inherits UserControl
Public Class Person
    Public Property PersonName As String
    Public Property PersonRole As String
    Public Property PersonLength As String
End Class

Private Sub UserControl_Loaded(sender As System.Object, e As        System.Windows.RoutedEventArgs) Handles MyBase.Loaded
    Using ctx As New sp.ClientContext("http://localhost")
        'Dim ctx As sp.ClientContext = sp.ClientContext.Current

        Dim _List As sp.List = ctx.Web.Lists.GetByTitle("pfa")
        'Dim _Query = sp.CamlQuery.CreateAllItemsQuery

        Dim _Query As New sp.CamlQuery()
        _Query.ViewXml = "<View><Query><Where><IsNotNull><FieldRef Name='FullName' /></IsNotNull></Where></Query></View>"

        Dim _ListItemCollection As sp.ListItemCollection = _List.GetItems(_Query)
        Dim _People As New List(Of Person)
        MessageBox.Show("Just Before Loop")
        For Each _ListItem As sp.ListItem In _ListItemCollection
            Dim _Person As New Person
            _Person.PersonName = _ListItem.FieldValues("FullName")
            _Person.PersonRole = _ListItem.FieldValues("Role")
            MyOutput.Text += _Person.PersonName & vbLf & _Person.PersonRole

    End Using
End Sub
End Class
  • To get more details about the exception, You should use try catch block. Update your question with the exact exception details to get better answers – gravinskm Oct 12 '12 at 16:13
  • try accessing field values like _ListItem.("FullName") – Arsalan Adam Khatri Oct 15 '12 at 10:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.