3

I am working in Windows Application. My req. that i need to create the SharePoint 2007 and SharePoint 2010 layers for that project.

Can we use the SharePoint 2007 and SharePoint 2010 version of dll in One Project?

John Saunders
  • 160,644
  • 26
  • 247
  • 397
Basant B. Pandey
  • 345
  • 7
  • 22
  • I understand that its a Windows Application. How are you planning to use the DLL for 2007 version? Will the app run in the server? – Shoban Feb 10 '12 at 06:22
  • I've been advised by a colleague that it can't be done however he was unable to give me anything specific to back this claim up (which is why this is a comment and not an answer). I'll see if I can spare some time later today to test this for you. – Michael A Feb 10 '12 at 07:05
  • @Shoban Yes Application is run on the Server. – Basant B. Pandey Feb 10 '12 at 07:44
  • Thanks @Michael Please check let me know if this possible. If not then what are the alternative ways to do that. – Basant B. Pandey Feb 10 '12 at 07:46
  • Even I feel this can't be done. What is that you are trying to do specific with 2007 version? Can't you do it with the 2010 version? – Shoban Feb 10 '12 at 09:35
  • @Shoban if I need to run My application on both Moss and SharePOint 2010, So I need this type of functionality. – Basant B. Pandey Feb 10 '12 at 10:34
  • I am part of [Sharepoint SUSHI](http://sushi.codeplex.com/) and we have different EXEs for 2007 and 2010 versions :) – Shoban Feb 10 '12 at 10:41
  • @Shoban thanks, But I have question from you can we use the SharePoint 2007 dll in SharePoint 2010? – Basant B. Pandey Feb 10 '12 at 10:49

1 Answers1

1

So you want your application to work on both SharePoint 2007 and 2010, correct?

You have two choices :-

A) The simplest is to just reference the SharePoint 2007 DLL's in your project and make a small change to the package manifest to remove the SharePointProductVersion attribute.

This will then work fine on SharePoint 2007 and on SharePoint 2010 there are BindingRedirects already setup so that 2007 web parts will 'just work' on 2010.

See "Developing SharePoint 2007 Webparts using Visual Studio 2010"

However - this means that you can't use any of the new SharePoint 2010 features that were not around in 2007

B) A more advanced method is to use some MSBUILD ninja moves to output two 'targets' (versions of your program) - one targeting 2007, one 2010. You modify the .csproj file to reference the appropriate version of Microsoft.SharePoint.dll and use conditional compilation to keep the same source code with minor differences where necessary. Its pretty advanced stuff and rarely necessary so I am not going to go into details here - but you've got keywords for further research if necessary.

Ryan
  • 23,871
  • 24
  • 86
  • 132
  • Thanks @Ryan, but I question related to the Window Application not for SharePoint Web Part related. I have a window application.I need that application to work on both both SharePoint 2010 and WSS. Did you have any idea related to that. – Basant B. Pandey Feb 13 '12 at 12:21
  • Web part or windows app doesn't matter. You're using the SharePoint object model by referencing Microsoft.SharePoint.dll so its the same answer either way. – Ryan Feb 13 '12 at 14:33