Archives / 2009 / December
  • Summing up the year of 2009 and embracing 2010

    Tags: Personal, SharePoint, Windows Mobile, Windows 7, CodePlex, SharePoint 2010

    The year of 2009 is about to close and it’s time for me to summarize this year, as I’ve done for the last few years (2006, 2007 and 2008). This year has been one of the most inspiring and exciting years for me in a very long time. I have been doing so much fun stuff this year.

    The most significant change has been starting to work for my new employer Connecta (after nine years at basically the same employer). I needed some new challenges and I now work with some really talented people from whom I learn and share so much. As you readers know, it’s all about SharePoint for me and I have done some awesome projects this year that I’m proud of and really looking forward to some SharePoint 2010 gigs. I also finally got my MCT certification and already scheduled a number of courses for next year, looking forward to meet some aspiring SharePoint students!

    Another really cool thing is that just a few weeks ago I signed a contract with Manning Publications about writing a book on SharePoint 2010, first chapter is due in a few days. This is something that I wanted to do for some time; it’s hard work but it makes me get even better – and that’s why I’m in the game. More details on the book in an upcoming post…


    I continued to blog about things that I’ve found interesting – not as much as I had hoped for. I’ll try to get better next year, even though focus will be on the book for the first few months. But if I take a look at the statistics it looks like it has been a great year – thank you all new followers. The most popular post this year has been:

    1. Running SharePoint on Windows 7 – one of the first things I did on Windows 7
    2. Creating SharePoint 2010 workflows with Visio 2010 – awesomeness in a box
    3. SharePoint Service Pack 2 known, found and experienced problems – there are always problems
    4. Web Part Properties - part 2 - Editor Parts – great response on this series
    5. Web Part Properties - part 3 - the .webpart file – a runner up…

    SharePoint Community

    I’ve made a big commitment to the SharePoint community this year – and I like it, I like it a lot! It has been so fun and rewarding commenting, tweeting and meeting with the incredible SharePoint community. Can’t imagine any other community that has so much fun together! Unfortunately I missed the highlight conference in Las Vegas and the chance to listen and meet the rest of you, due to the change of employer. I hope I can make it for another year.

    Here in Sweden we started the site to gather all SharePoint interested people and the Swedish SharePoint User Group under one umbrella and we have reached close to 500 members. The User Group here in Sweden have had some great meetings and presentations with a great number of people. Thank you again to all speakers and participants. Next year will be awesome!

    Speaking engagements

    I’ve been fortunate to have had a few presentations for the Swedish SharePoint User Group (in February two sessions and one in September) but the most fun presentations I’ve had was the one in Copenhagen at the first European SharePoint Saturday and the one at the Swedish SharePoint and Exchange Forum. It was awesome meeting all these cool people I only have had 140 characters discussions with. One of my first assignments with my new employer was a SharePoint 2010 seminar which we presented on a huge cinema screen in an almost full theatre – just loved it! I hope I will get more opportunities in 2010 do some more SharePoint love!

    Personal Projects

    As always I fiddle around with SharePoint as much as I can and I finished version 2 of ChartPart, which you can find on Codeplex. ChartPart v 1 had about 10.000 downloads and version 2 has had close to 3.000 now (and 4.000 in beta). Together with Keith Dahlby I got the SharePoint Extensions Library out – and I’ve received very good feedback on it. Two other projects also ended up on Codeplex; Windows Live ID Authentication for SharePoint and TweetPart. I will try to get these updated to support SharePoint 2010 to 100%.

    Last years predictions

    Last year I did some predictions, as I’ve done now for a couple of years. I guessed that 2009 will be a year of constant betas – and man I was right. Windows 7 betas, Office 2010 betas and SharePoint 2010 betas has been making my days wonderful/peculiar this year. I predicted that Office 14 would hit the streets – now we now that we won’t get the final bits until mid 2010. I was right about Internet Explorer 8 and Windows 7. I also predicted that Microsoft would go for more open source projects and I think they very well have lived up to that – just take a look at Codeplex where Microsoft have released a great amount of awesome projects.

    Predictions for 2010

    What about 2010 then? We all now that Microsoft is focusing everything on Office 2010 and SharePoint 2010 and they will continue grow even stronger. But I think that during the later parts of 2010 Microsoft will have something extraordinary coming in Windows Mobile 7. They must have, otherwise it’s game over for sure for Windows Mobile.

    Another thing we will see starting emerge from Redmond is a new Internet Explorer, it’s loosing market shares, so I expect some major improvements in standards compatibility and of course some new creative thinking.

    Thank you and a happy new year

    That’s all folks. The last year of this decade is over and it’s time to grab the bull by it’s horn and face a new one…

    Happy new year!

  • Improve your SharePoint 2010 applications with monitoring using SPMonitoredScope

    Tags: SharePoint 2010

    SharePoint 2010 comes equipped with a set of new tools to improve the monitoring of your custom applications, there are built-in functionality to check how long your operations take, how many SQL Server calls are done etc. All this is logged and can be visualized in the Developer Dashboard.

    Developer Dashboard

    Another good thing with this is that it’s not something that just automatically is there but you can also hook yourself into the monitoring and the actual Developer Dashboard.

    Monitoring your custom code

    There are many cases when you run into trouble in production, due to the fact that some parts are running slow or even makes your entire farm run on its knees. This can be because you are running a SQL query that takes forever, a never-ending loop or a Http request that takes just too long. In previous versions of SharePoint you either had to write custom code to log these conditions or write to the ULS logs, I even wrote my own event logging provider once to monitor the executed code.

    Monitored Scopes In SharePoint 2010 everything is executed under a so called Monitored Scope. Each scope has a set of Monitors that measures and counts calls and timings – and this is what get’s logged in the Developers Dashboard. If you take a look at the image on the right you can see that the calls are nested and each row represents a monitored scope. At the end of each scope all monitors are evaluated and if anyone of the exceeds their limits this is logged (or if you have turned on verbose logging it always is logged).

    You can very easily make your own monitored scope – and I think that you should do that from now on in all your SharePoint 2010 projects. It will help you one day!

    For example if I have a Web Part that is running an operation that could take some time, for example a web service call, I could write code like this to start my scope:

       1:  protected override void OnPreRender(EventArgs e) {
       2:      using (SPMonitoredScope monitoredScope = 
       3:             new SPMonitoredScope("Long Call")) {
       4:          longCall();
       5:      }
       6:      base.OnPreRender(e);
       7:  }
    On line 2 i create a new object of the type SPMonitoredScope and give that scope a name (“Long Call”). Inside that scope my code that might take long time is running (line 4). If the Developer Dashboard is turned on, this scope will be visible, see image below on the third line.


    This is a very easy way to improve the logging of your application.

    Worth noticing is that this will not work for Sandboxed applications, they run in a separate process.

    Custom monitors

    Just logging your scopes in the developers dashboard is one thing but you also sometimes would like to make sure that you monitor how many times this code is executed. Let’s say that you are using a web service that you pay per use of, then it would be nice to monitor how many times you are querying the web service and optionally refuse usage if it exceeds your budget.

    As I said before SharePoint 2010 always adds a set of monitors to your scopes (the parent scope actually) that monitors time, SQL queries etc. And you can do the same.

    All you have to do is to create a new class and inherit from ISPScopedPerformanceMonitor and then implement that interface. To get this monitor into your scope you have to pass it as a parameter to your SPMonitoredScope constructor like this:

    using (SPMonitoredScope monitoredScope = 
           new SPMonitoredScope("Long Call", 1000, new TheMonitor())) {...}

    You can pass in as many monitors as you like.

    In the code above your custom monitor is TheMonitor and it could look like this:

       1:  public class TheMonitor: ISPScopedPerformanceMonitor{
       2:      static int s_times;
       3:      static TheMonitor() {
       4:          s_times = 0;
       5:      }
       6:      public TheMonitor() {
       7:          s_times++;
       8:      }
       9:      public void Dispose() { }
      11:      public string Description {
      12:          get { return "The Monitor"; }
      13:      }
      15:      public string Name {
      16:          get { return "TheMonitor"; }
      17:      }
      19:      public string RenderValueForWeb() {
      20:          return string.Format("MONITOR: {0}",s_times);
      21:      }
      23:      public object Value {
      24:          get { return s_times; }
      25:      }
      27:      public bool ValueIsExcessive {
      28:          get { return s_times > 5; }
      29:      }
      30:  }

    This monitor class will count each time this monitor is called (in the constructor, line 7) and if it’s called more than 5 times the threshold value has been exceeded. (Note: this implementation will not work in production and contains no threading support). At the end of each scope, when the SPMonitoredScope is disposed it will check all monitors using the ValueIsExcessive and if that method returns true it will be logged to the ULS logs.

    This is an excerpt from a ULS log using the monitor above:

    Entering monitored scope (Long Call)
    Leaving Monitored Scope (Long Call). Execution Time=999.885180937801
    ____Execution Time=999.885180937801

    I hope this post inspired you to produce code that can be monitored more easily using the SharePoint 2010 built-in features.

    Merry Christmas to you all!

  • Swedish SharePoint User Group December 09

    Tags: SharePoint, Presentations

    Yesterday we had a Swedish SharePoint User Group meeting, hosted by Connecta (yes, my new employer). We had a new record with number of participants, over 60 interested SharePointers of all kinds showed up to listen to MVP Göran Husman, Humandata, talk about the news in SharePoint 2010 and Peter Karpinski, Microsoft Services, talk about how to do Rapid Application Development with SharePoint 2010, SharePoint Designer 2010, Visio 2010 and InfoPath 2010 and how to script you SharePoint 2010 installs. Thank you for great shows and thanks to everyone who showed up.

    I hope we can continue this trend and have as many people in each meeting and there will be meetings in other cities than Stockholm during next year.

    MVP Göran Husman Peter Karpinski
    Mattias Karlsson, MVP Tobias Zimmergren, Joakim Hägglund and Tony Reistano Peters laptop after SSD quality testing...

    I also did a short intro presentation about the survey we had earlier this autumn about the UG meetings. And from that survey I think that we will have meetings every other month or so (depending on how much people will engage). A lot of new people was interested in having a session and/or wanting to host future meetings – expect to be contacted soon for next meeting. We discussed having a meeting during Techdays 2010 in March and can hopefully squeeze one more in before that.

    Post will be updated when I have Görans and Peters presentations and Peters Awesome Install SharePoint With No Hands scripts.

  • Four interesting changes to the SharePoint Foundation 2010 API

    Tags: SharePoint 2010

    Working with SharePoint 2010 is really a joy, you stumble upon great things all the time. The API has not had any revolutionary changes to be backwards compatible; but small changes here and there, both publically visible and internally, really makes the API better than before.


    To get the Content Type Id of an SPListItem you had to first get the SPContentType from the SPListItem.ContentType and then get the Id of the content type. This method was one marked as internal in version 12, but is now marked 14. It’s those little things. There are actually a lot of previously internal properties and methods that now are public, for example the CanBeDisplayedInEditForm property on the SPField class.

    SPListCollection.TryGetList(string listTitle)

    Last year I wrote a post about this one and now it’s there. No need to encapsulate your code with try-catch blocks when trying to get a list using it’s name. TryGetList will return null if the list does not exist. Thank you guys, up there in Redmond!

    SPWebPartManager disposes the SPWeb object

    One change that is really great. When using the SPWebPartManager or the SPLimitedWebPartManager you previously had to manually dispose the SPWeb object before disposing the Web Part manager, now that’s done when disposing the SPWebPartManager or the SPLimitedWebPartManager. This will save a lot of people a lot of memory leaks.


    This is an interesting one, using this method you can find out which sites and lists a specific field is used. The method returns a collection of SPFieldTemplateUsage objects, which contains Guids of the list and site Id’s. One thing that also is interesting with this one is the usage of the templated ICollection instead of an array or custom collection.

    There are of course a lot more, but these four I did find during my excavations this weekend. Have you found any favorite change except the obvious ones?

  • My SharePoint 2010 development rigs

    Tags: SharePoint 2010, VMWare, Virtual PC, Windows Server 2008 R2

    SharePoint 2010 is one greedy beast and you can’t settle with your plain old laptop; first of all you need a x64 bit environment and second of all you need some RAM. Developing for SharePoint 2007 required just a 32-bit machine, less than 4 gigs of RAM and Virtual PC and you could do most of your work without complaining to much. SharePoint 2010 requires some more thought through development environment .

    First of all you need a 64-bit platform and at least 8GB of RAM, that’s what I’m having now on my HP EliteBook 6930p. So far this machine has worked really smooth; I run Windows 7 as the main OS on it.

    Second, you can’t use Virtual PC – it’s 32 bit only! So if you like to live in the Microsoft world you have to install a Windows Server OS on your laptop of use Windows 7 VHD boot. I want to have access to my desktop applications and my main OS so I’ve walked down the VMWare path a couple of months ago and I’m currently using VMWare Workstation 7 – it’s an awesome virtualization software and I am not going back!

    Third, you need disk space – go get some USB or ESATA hard drives. If you are going to have a single setup of your SharePoint 2010 virtual machine – this may not be necessary, but if you are like me and like to be able to create snapshots, have multiple clones, non-expanding virtual disks then most probably your internal laptop disk won’t last long.

    I have two main sets of SharePoint 2010 development rigs right now:

    • A single virtual machine approach
    • A multiple virtual machine approach

    Single Machine Approach

    The single virtual machine SharePoint 2010 is an easy option; it’s a Windows Server 2008 R2 machine with 4-6GB of RAM and it runs everything from Active Directory to SQL Server to SharePoint to Visual Studio 2010. This rig is great if I want to do something quick.

    Multiple Machine Approach

    This rig is more complex, but also offers a better flexibility. VMWare Workstation offers you to create teams of virtual machines and I’ve set up a team of three servers:

    • 1 Windows Server 2008 R2 Core running Active Directory with 512 MB of RAM
    • 1 Windows Server 2008 R2 running SQL Server 2008 with 1024 MB of RAM
    • 1 Windows Server 2008 R2 running SharePoint 2010 and all apps with 4096 MB of RAM

    I find this multiple machine approach to be better performing, although it takes longer to start up and to shut down. Creating the Server Core machine with AD is probably the best thing about it, took me some time to get acquainted to the Server Core environment, but with some PowerShell love it worked like a charm.

    Only drawback with the VMWare team approach is that you can’t run your machines in Unity mode.

    I will try a third option; AD on Server Core on one machine and the rest on a single server – I think it will work great as well.

    Other machines

    I also have a Windows 7 virtual machine, that is joined to the domain and a Ubuntu Linux machine – which I’m using for demoing Office Web Applications and the SharePoint 2010 interface.

    All these setups are made with clean and compressed snapshots so that I easily can clone up a new empty environment whenever I need it.

    How is your SharePoint 2010 development environment?

About Wictor...

Wictor Wilén is the Nordic Digital Workplace Lead working at Avanade. Wictor has achieved the Microsoft Certified Architect (MCA) - SharePoint 2010, Microsoft Certified Solutions Master (MCSM) - SharePoint  and Microsoft Certified Master (MCM) - SharePoint 2010 certifications. He has also been awarded Microsoft Most Valuable Professional (MVP) for seven consecutive years.

And a word from our sponsors...