SharePoint 2010 ExecuteQueryAsync - ClientRequestFailed

Locked SharePoint 2010 ExecuteQueryAsync - ClientRequestFailed

  • Sunday, October 23, 2011 4:22 PM
     
      Has Code
    namespace SPSilverlightExample
    {
        //************************************************
        public class Project
        {
            public string Title { get; set; }
            public DateTime DueDate { get; set; }
            public string Description { get; set; }
            public DateTime EndDate { get; set; }
        }
        //************************************************
        public partial class MainPage : UserControl
        {
            private ListItemCollection _projects;
    
            public MainPage()
            {
                InitializeComponent();
                //************************************************
                ClientContext context = new ClientContext(ApplicationContext.Current.Url);
                context.Load(context.Web);
                List Projects = context.Web.Lists.GetByTitle("Projects");
                context.Load(Projects);
    
                CamlQuery query = new Microsoft.SharePoint.Client.CamlQuery();
                string camlQueryXml =   "<View><Query><Where>" +
                                        "<And><And>" +
                                        
                                        "<Gt>" +
                                        "<FieldRef Name='DueDate' IncludeTimeValue=\"TRUE\" />" +
                                        "<Value Type='DateTime'>2000-01-01T00:00:00Z</Value>" + 
                                        "</Gt>" +
                                        
                                        "<Lt>" +
                                        "<FieldRef Name='EndDate' IncludeTimeValue=\"TRUE\" />" + //"Lt" = Lower Than
                                        "<Value Type='DateTime'>2012-10-20T00:00:00Z</Value>" +
                                        "</Lt>" +
                                        
                                        "</And>" +
    
                                        "<Eq>"+
                                        "<FieldRef Name='Custom_x0020_Column' />" +
                                        "<Value Type='Text'>Room1</Value>" +
                                        "</Eq>"+
    
                                        "</And>" +
                                        "</Where></Query>"+
                                        
                                        "<ViewFields>" + //Felder anzeigen = Titel; DueDate; Description; EndDate
                                        "<FieldRef Name=\"Title\" /><FieldRef Name=\"EndDate\" />" +
                                        "<FieldRef Name=\"Description\" /><FieldRef Name=\"DueDate\" />" +
                                        "</ViewFields></View>";
    
                query.ViewXml = camlQueryXml;
                _projects = Projects.GetItems(query);
                
                context.Load(_projects);
                context.ExecuteQueryAsync(new ClientRequestSucceededEventHandler(OnRequestSucceeded), null);
                //************************************************
            }
            //************************************************
            private void OnRequestSucceeded(Object sender, ClientRequestSucceededEventArgs args)
            {
                // This is not called on the UI thread.
                Dispatcher.BeginInvoke(BindData);
            }
            //************************************************
            private void BindData()
            {
                int i = 0;
                List<Project> projects = new List<Project>();
                foreach (ListItem li in _projects)
                {
                    projects.Add(new Project()  
                    {
                        Title = li["Title"].ToString(),
                        DueDate = Convert.ToDateTime(li["DueDate"].ToString()),
                        Description = li["Description"].ToString(),
                        EndDate = Convert.ToDateTime(li["EndDate"].ToString())
                    });
                    i++;
                    //int i = Convert.ToInt32(_projects.Count());
                }
                MessageBox.Show(i.ToString(), "EXIT", MessageBoxButton.OK);
    
                //dataGrid1.ItemsSource = projects; //Muss im User Interface enthalten sein - am Anfang hinzufügen
            }
            //************************************************
        } //Main-Class END
    
    }
    

    Hello @All,

    I have a question to my code above: This is a Silverlight WebPart that runs on Share Point 2010 and on my local machine this code works fine. But when I try to run it on a MS Server 2008 R2 the function:

     

    context.ExecuteQueryAsync(new ClientRequestSucceededEventHandler(OnRequestSucceeded), null);
    

     


    Doesn't work. It goes to the NULL-Tree and doesn't do anything.

    What can be the reason? Maybe a security problem?

    //EDIT: Sorry for double-posting: http://social.msdn.microsoft.com/Forums/en-US/sharepointdevelopment/thread/ac15ea42-a054-443d-a8fb-1300caaeec05

     

    Kind regards,

    ms





    • Edited by MiKiii_ Sunday, October 23, 2011 4:24 PM
    • Edited by MiKiii_ Sunday, October 23, 2011 4:33 PM
    • Edited by MiKiii_ Sunday, October 23, 2011 4:34 PM
    • Edited by MiKiii_ Sunday, October 23, 2011 4:34 PM
    •  

All Replies