Writing to the SharePoint 2010 ULS

ULS stands for Unified Logging Systems, and it is a SharePoint component that produces log files under the 14 folder. A very easy way to read it is to use some of the tools presented in my previous blog post SharePoint ULS viewers. Btw, at least and according to me, the best one is still the Microsoft ULS Viewer.

The good news is that custom code can write to the ULS too, so in this way it is possible to have a single point of tracing.

In the Microsoft article Trace Log Example you can find an example of a custom tracer.

And in the post Logging to ULS in SharePoint 2010 is it possible to find a custom LoggingService writing the name of the tracing application.

Considerations developing SharePoint 2010 client applications

Here are a few considerations developing client applications accessing the SharePoint 2010 object model:

  • the target processor must be x64 (the default is x86 instead);
  • you need to use .NET framework 3.5 and not 4.0.

As noted in the post SP2010: SharePoint not supported with .NET framework version, these bugs were present since the beta of SharePoint, but they haven't been fixed yet.

Dynamic Language Extensions in C# 4

C# 4 introduces the dynamics.

In contrast to the var keyword, witch the type is determined at compile-time, the dynamic keyword is type safe too, but its type is determined at runtime.

There are then:

  • the DynamicObject class: you have to derive from it, and implement the TryGetMember, TrySetMember and TryInvokeMember methods;
  • the ExpandObject: this class is sealed and you have to use it as it is.