Serialization in Sandbox Solutions

If you have the pleasure of writing sandbox solutions, perhaps for Office365, you know that doing so involves a wide variety of creative workarounds. Serialization is one area where this creativity comes into play.

The problem with the XMLSerializer is that it creates and loads a serialization assembly on the fly. This doesn’t work in the sandbox. A good discussion and one solution to this problem is discussed here: Using the Application Setting Manager in Sandboxed Solutions.
An alternative approach is discussed here: Serialization Inside SandBox Solutions.

My alternative is to avoid XML Serialization altogether and use JSON via the JavaScriptSerializer class. This lovely class does not require an assembly and it works. Best of all, it creates a format that is easy to use in JavaScript which I tend to use heavily in SandBox solutions.

A terrific overview of this class can be found here on Rakki Muthukumar’s blog: ASP.NET – JSON – Serialization and Deserialization.

 

Author: Doug Ware

Creating List Indexes with the SharePoint Object Model

Many scenarios in SharePoint 2010 require you to create indexes on lists – e.g. enforcing unique values, CAML joins, and referential integrity. I was writing some code yesterday that needed an index and I wasn’t able to find a sample – so I figured I’d put up a quick post.

Before you get started, understand that you can only index certain field types and that compound indexes are even more restricted. See this page for the types of indexable fields: Metadata Navigation and Filtering.

Here is the sample c# code. (list is an instance of SPList for the list that will be indexed)

Single Column Index

SPField title = list.Fields["Title"];
title.Indexed = true;
title.Update();

list.FieldIndexes.Add(title);

Compound Index

SPField createdBy = list.Fields["Created By"];
createdBy.Indexed = true;
createdBy.Update();

SPField created = list.Fields["Created"];
created.Indexed = true;
created.Update();

list.FieldIndexes.Add(createdBy, created);

Author: Doug Ware

Atlanta Code Camp 2011–June 25

At long last, we’re happy to announce the 2011 edition of the Atlanta Code Camp which will be held at the Southern Polytechnic State University.

Event Details

Call for Speakers:

click here

Registration:

click here

Date:

Saturday, June 25th

Registration Time:

7:45AM to 8:30AM

Time:

8:30AM to 5:30PM

Location:

Southern Polytechnic State University in Marietta, GA

Address:

1100 South Marietta Parkway, Marietta, GA 30060 (directions)

Cost:

This event is free to everyone that wishes to attend, as long as capacity is not exceeded in the event facilities.

Breakfast and Lunch:

Free of charge

   

If you’re not familiar with code camps, they are free community‐focused events by and for the .NET developer community. The Atlanta Code Camp draws upon the expertise of local and regional developers, architects, and experts who come together to share their real world experiences, lessons learned, best practices, and general knowledge with other interested individuals.

This event is unique in that it is "for the community, by the community" and is free for all that desire to attend. In past years, the Atlanta Code Camp has provided free training and networking opportunities for 300 of the best, most motivated development professionals. With our larger facility, we’re expecting this year to be even bigger and better.