Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

When I try to run this async query it fails:

    private void SomeFunction()
    {
        Thread thread = new Thread(GetBlogInfo);
        thread.Start();
    }

    private void GetBlogInfo()
    {
        this.clientContext = new ClientContext(this.strMySiteBlogUrl);
        this.oWeb = this.clientContext.Web;
        this.clientContext.Load(this.oWeb);

        this.oList = this.oWeb.Lists.GetByTitle("Posts");
        this.clientContext.Load(this.oList);
        CamlQuery query = new CamlQuery();
        query.ViewXml = "<View><Query><OrderBy><FieldRef Name='PublishedDate' Ascending='FALSE'></FieldRef>" +
            "</OrderBy></Query><ViewFields><FieldRef Name='Title'/><FieldRef Name='Body'/>" +
            "<FieldRef Name='PublishedDate'/></ViewFields><RowLimit>1</RowLimit></View>";
        this.oListInfo = this.oList.GetItems(query);
        this.clientContext.Load(this.oListInfo);
        this.clientContext.ExecuteQueryAsync(onQuerySucceeded, onQueryFailed);
    }

This is within a Silverlight Application, fyi. I thought it was a threading issue, but it just says:

  • Exception {System.Security.SecurityException ---> System.Security.SecurityException: Security error. at System.Net.Browser.BrowserHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult) at System.Net.Browser.BrowserHttpWebRequest.<>c_DisplayClassa.b_9(Object sendState) at System.Net.Browser.AsyncHelper.<>c_DisplayClass4.b_1(Object sendState) --- End of inner exception stack trace --- at System.Net.Browser.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod, Object state) at System.Net.Browser.BrowserHttpWebRequest.EndGetResponse(IAsyncResult asyncResult) at Microsoft.SharePoint.Client.ClientContext.OnGetResponse(IAsyncResult asyncResult)} System.Exception {System.Security.SecurityException}

Any ideas?

share|improve this question
    
does the user account running the script have permission to the site? –  David Lozzi Feb 17 '12 at 20:59
    
I'm wondering if this is because of MySites being on a separate web application... I'm looking into work arounds... –  RJ Cuthbertson Feb 17 '12 at 21:00
    
Yes, definitely, I'm actually on a dev set up, pulling my own user blog –  RJ Cuthbertson Feb 17 '12 at 21:00
    
What line is it erroring on exactly? –  David Lozzi Feb 17 '12 at 21:02
1  
solved. It was because MySites is hosted on a separate Web Application. Configuring the ClientAccessPolicy.xml solved my problem. There is a sample on this page: dev4side.com/community/blog/2010/8/15/… And best practice guidelines for production here: msdn.microsoft.com/en-us/library/cc645032(VS.95).aspx –  RJ Cuthbertson Feb 17 '12 at 21:10

1 Answer 1

up vote 1 down vote accepted

Configuring the ClientAccessPolicy.xml solved my problem.

There is a sample on this page:

http://www.dev4side.com/community/blog/2010/8/15/security-error-using-sharepoint-2010-client-object-model-for-silverlight.aspx

And best practice guidelines for production here:

http://msdn.microsoft.com/en-us/library/cc645032(VS.95).aspx

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.