Showing posts from March, 2011

Using the SharePoint 2010 Silverlight Client Object Model to Update Documents

Earlier this month, I blogged on how you can use the Silverlight client object model to retrieve files from a SharePoint document library . This time, let's take a look at how you can add or update files in a document library from Silverlight. Just like the process for retrieving files, the process for adding or updating files differs between managed .NET clients and Silverlight clients. The Silverlight client object model does not support the File.SaveBinaryDirect method, so the recommended approach for managed clients is not available to us. From a Silverlight client, the high-level process is as follows: Convert the contents for your new file to a byte array Create a FileCreationInformation instance to represent the new file Add the file to a folder in a document library The code should resemble the following: ClientContext context = ClientContext.Current; String fileContents = "This is the contents of my file"; String fileUrl = String.Format(@"{0}/{1}/{2}/{3}&

SharePoint 2010 Query Thresholds Bite You When You Least Expect It

In a previous post, Understanding List Query Throttling Limits in SharePoint 2010 , I talked about how SharePoint 2010 applies query throttling to list queries and how you can work around the query thresholds. In this post I just wanted to add how list query thresholds can cause errors when you least expect it. Today I was trying to export a SharePoint team site as a WSP. The Save site as template operation kept failing with an unexpected error. I took a look at the event logs, and found the following exception message: Error exporting the list named "BigList" at the URL: Lists/BigList "Fine", I thought to myself. I'm not particularly interested in that list, I'll simply delete it. I tried to delete the list and got hit with another runtime error. This time the event logs were more helpful: Exception type: SPQueryThrottledException Exception message: The attempted operation is prohibited because it exceeds the list view threshold enforced by the admin

Using the SharePoint 2010 Silverlight Client Object Model to Retrieve Documents

This week I've been working on migrating a Silverlight application to SharePoint 2010. The application in question uses some fairly complex XML files as a data source, and currently relies on a custom Web service to retrieve and update these files. We want to modify the application to retrieve the XML files from a SharePoint 2010 document library. MSDN provides a good article on how to use the managed .NET client object model for SharePoint 2010 to retrieve and update documents in a SharePoint document library. However, this scenario becomes a little more challenging from a Silverlight client, as some of the required classes are unavailable in the Silverlight version of the client object model. When you work with the managed client object model, the recommended approach for retrieving the contents of a file is to call the synchronous File.OpenBinaryDirect method. This returns a FileInformation instance that exposes the contents of the file as a stream. However, the FileInformat

Where Are the SharePoint Client Assemblies?

If you're reading this post, you probably know that SharePoint 2010 provides client-side APIs for Silverlight apps, managed .NET clients, and JavaScript code. However, the assemblies you need in order to start developing SharePoint client apps can be elusive at first. In particular, the Silverlight assemblies aren't where you might expect. All the assemblies and JavaScript libraries that you need for client-side development are deployed to folders beneath the SharePoint root when you install SharePoint 2010. For the record, here's where you can find them. If you’re developing a managed .NET client application—for example, a WPF application—you need to add references to Microsoft.SharePoint.Client.dll and Microsoft.SharePoint.Client.Runtime.dll . You can find them in the 14\ISAPI folder on your SharePoint server. If you’re developing a Silverlight application, you need to add references to Microsoft.SharePoint.Client.Silverlight.dll and Microsoft.SharePoint.Client.Silverli