Today and tomorrow I’m spending my time in AddSkills seminar SharePoint Advanced Development with Shannon Bray. Shannon is a well-known SharePoint expert and Microsoft’s SharePoint MCT. The seminar is focused on real-world problems. We also got the book “Inside Microsoft Windows SharePoint Services 3.0” by Ted Pattison and Daniel Larson which is supposed to be one of the best books on SharePoint development.

This blog post is my way of cleaning up my notes and a place to keep them to look back at when I need to.
I don’t have any demonstration code in this post, that will have to wait until future posts when I try some of these things out.

[more]

Right from the start I could feel that the level of the seminar was perfect for my own knowledge and I got many aha-moments.
Shannon explained the difference between application and site pages and showed an example building an application page in Visual Studio, putting the solution directly in the _layouts-folder. Nice touch and something I will remember for my next project.

There was a lot of information to cover but it never felt like we rushed through anything.
We saw some nice demos of how to programmaticallly create lists and fill them through the API. In my mind I saw the use for this in a current project to be sure that a specific list exists and if not, create it and fill it with default values.

In order to work with lists and other components of SharePoint through the API we need to set SPWeb.UnsafeUpdates = true, we could also use something called FormDigest which is completely new to me. Something I need to check out.

Through the SecurityAPI it’s also possible to set permissions, adding users to security groups and so on. Some of this I’ve tried already. I have a situation where I need to fill a drop-downlist with users from a specific security group.

Here’s something I didn’t knew and never thought of: when a list is more than 2000 items we start to see real performance hits. Using filtering becomes important so we have smaller selections to work with.

There are different ways to create site definitions. We can copy an existing and start changing files or use tools such as WSPBuilder and Site Definition Generator. If we do use site definitions it’s important to think about what we might have to do in the future. If an included feature change in the definition, it is not changed in sites created before the change was made to the site definition. One way to solve this is to start with an empty site definition and then use feature stapling for all features. That way we can easily update sites created before the changes was made.

SharePoint uses Lists for everything but it’s also possible, and sometimes necessary, to use SQL-tables instead. Let’s say we have a list with customers containing customer number and name. That’s not a problem keeping in a list. But if we also want to add multiple addresses a table suits better. For a large number of items and/or complex data relationships we use the tables.

When it comes to deploying dll:s they can be put in the bin folder or in the GAC. There’s a big difference in security here. A dll in the bin is controlled by the trust level set in the web.config. The one in the GAC always have full trust. If this is a web part put in the bin and the trust level need to be meduim to be able to program against the API.

When setting up a team environment there are a few things we should keep in mind.

  • Use a Virtual PC
  • Set the RAM for the VPC to a minimum of 2GB.
  • Use Host Headers
  • Use SQL Aliases
  • Develop in feature sets

These few points makes it easier to use one developer’s code on another machine.

One of the most important parts of SharePoint development is packaging and deployment. Usually we use XCopy when starting out, I did, to copy our files to the different servers. Instead we should package our web parts and features in solution packages. These wsp-packages can then be deployed to the farm and to all sites they are needed at.
Some tools we may use are WSPBuilder (new version released on April 10th) or the SharePoint Extensions for Visual Studio.

A big problem debugging SharePoint is the error messages. They don’t say anything. But we can easily get verbose errors with a few changes in the web.config. Set CustomErrors=”Off” and CallStack=”true” and you will get the complete error message.
We can also do in process debugging. Go to Debug / Attach to process and select w3wp.exe. If there are more than one you can select them all by using Ctrl. Or do an iisreset, open the site in the browser and then attach. It should only be one instance of w3sp.exe.

Shannon also showed some features in Visual Studio 2008 Team System. There’s a really cool way to record web tests by clicking through the site and then set up advanced load tests.

The last point of today was common coding issues such as caching and the importance of disposing objects created with new.
Caching can sometimes be hard since IIS is multithreaded. I’ll get back to this with some code examples in the future.
Objects created with new always have to be disposed of. This can be done either by using for example spSite.Dispose() or putting everything within a using block.
SPDisposeCheck is a tool used to check if objects are not being disposed of.

That was it for day one. Very good seminar and I learned a lot already. Really looking forward to tomorrow when we go deeper into the Business Data Catalog, feature development, enterprise search, web services and if we have time workflows.