2

I am writing a console application for SharePoint. Mostly, I will be using it for both MOSS and SharePoint 2010. I have two separate functions - one for MOSS and other for SharePoint 2010. In my Main method, I want to detect the version of sharepoint and call the funtion accordingly.

Please let me know the best way to do that.

1

Are you calling the SharePoint server API from within your console application? If so, I'm not sure this will work as you would need to reference and build your app against both the 2007 and 2010 version of the SharePoint.dlls. Visual Studio won't like that (unless you build against the 2007 version to run to the 2010 version)

| improve this answer | |
  • You are correct! Any idea how to do it then? – SP.NET Dec 13 '11 at 9:26
  • Depends on what you are doing inside the console application. You might find that creating a powershell script instead of a console app is a better option. – Paul Lucas Dec 14 '11 at 21:23
4

SPFarm.BuildVersion works with both 2007 and 2010.

http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.administration.spfarm.buildversion.aspx

| improve this answer | |
  • This will not work in my situation. See answer by Paul Lucas. – SP.NET Dec 13 '11 at 13:03
0

If you want to check which UI the SharePoint site is having, I would recommend to use SPWeb.UIVersion property of the current site. A value of 3 means it has the SharePoint 2007 interface and a value of 4 means that it has the latest SharePoint 2010 Interface.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.