Reaching a list from silverlight to sharepoint 2010

Although I have tried everything ,almost every code to get the contents of a list in sharepoint 2010 ,Why am I not able to get the files... below is my code:

            ClientContext ctx = new ClientContext("http://sharepoint-one");
             Site site = ctx.Site;
             Web web = site.RootWeb;

             ListCollection lists = web.Lists;

             List taskList = lists.GetByTitle("Shared Documents");

             CamlQuery query =CamlQuery.CreateAllItemsQuery();

             ListItemCollection listItems = taskList.GetItems(query);


I have a silverlight application this needs to get into a list in sharepoint and get the files inside... but somehow the code above gives the exception CollectionNotInitializedException in the first line even though the exception i can continue with F10 in debug mode but then it gives error in executequery saying that  :

The method or property that is called may block the UI thread and it is not allowed. Please use background thread to invoke the method or property, for example, using System.Threading.ThreadPool.QueueUserWorkItem method to invoke the method or property.

if I use ExecuteQueryAsync(Onsuccess,Onfailure); then it somehow does not go to onsuccess  or onfailure methods and continues like nothing happens and i cannot get list specific information...

like the count of the items inside the list with

             int count = 0;

             foreach (ListItem a in listItems)

when I try to get info about the list with above code I get the error msg below...

The collection has not been initialized. It has not been requested or the request has not been executed. It may need to be explicitly requested.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Are you using the Client Object Model? For Silverlight I believe you need to.
fatihdiAuthor Commented:
yes i am using client object model thats right
Here is some code from a workshop I took on SP2010 and Client Object Model. Hopefully it will help you.

using ClientOM = Microsoft.SharePoint.Client;

 using (ClientOM.ClientContext ctx = new ClientOM.ClientContext(textBox1.Text))
        ClientOM.Web site = ctx.Web;
            x => x.Lists.Where(l => l.Title != null));
        foreach (ClientOM.List list in site.Lists)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Thanks a lot quihong. That resolved the issue for me. Looks like you have to load the object and that did the trick for me.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.