Question

I have coded a solution that uses the 2007 API to traverse the SharePoint object model. Now I need to support SP 2003 as well. What is the best way to do this?

Is it possible / recommended to use the 2007 api to get access to a 2003 SharePoint Farm?

If I use the 2007 api, do I have to use the deprecated classes to (for instance) reference a configuration database, or do I use the 2007 classes, such as SPFarm?

Or do I use the 2007 API for SP 2007 and the 2003 API for SP 2003...? Problem with this is that both use the same namespaces and class names. So it can get messy. (Except maybe if I use aliases to reference the different namespaces?)

Was it helpful?

Solution

As far I know the 2007 API and the 2003 API are incompatible. So yes? you will need to implement both.

I can suggest to have interface ISharePointAPI and two implementations SharePoint2007API and SharePoint2003API. This implementations can even be packaged to different assemblies, so you will not have reference hell :). This is will also protect you from 2010 API changes as what you will need is to implement SharePoint2010API...

OTHER TIPS

The interfaces are (mostly) compatible in a namespace/class/member USAGE but you have to use the right version of the API for the correct version of SharePoint. You also have to consider that by WSS2/SPS2003 uses .NET1.1 by default.

My solution to this is to use MSBEE and some MSBUILD ninja moves to spit out two versions from your source code.

The first targets .NET2 and references Microsoft.SharePoint.dll v12 (WSS3/MOSS2007) and the second targets .NET1.1 and references Microsft.Sharepoint.dll v11 (WSS2/SPS2003).

Its quite a faf to setup but works very well after that. Where you do have code differences you can use conditional compilation :-

#if FX1_1
   // WSS2/SPS2003 specific code
#else
   // WSS3/MOSS2007 specific code
#endif

This article gives a little more detail. Its a big topic and I've been meaning to write a blog post with some tip.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top