Building SharePoint 2007 project for SharePoint 2010 in Visual Studio 2010

When you open SharePoint 2007 project in Visual Studio 2010 and click on Build/Rebuild command you will get following error message:

The type or namespace name 'SharePoint' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)

image

It is because in SharePoint 2007 you have referenced assembly with version 12 and SharePoint 2010 has 14. Visual Studio just can’t find your referenced assembly in the GAC.

When you will open References for your project in Solution Explorer you will see that included assembly it not found:

image

Remove this “not found” assembly from References. Otherwise Visual Studio thinks that your new assembly is the same.

If you project was based on .NET 2.0 framework and you will click on Add Reference, then you can’t find new SharePoint 2010 assembly in menu. It is because SharePoint 2010 assembly is build on .NET 3.5 framework and you should to change Visual Studio project .NET framework version.

  1. Right click on you project in Solution Explorer and click on Properties.
  2. “Application” tab
  3. Change in “Target framework” combo box framework`s version to .NET 3.5 or newer

image

Now go to “Add Reference” and now you are able to select new SharePoint 2010 assembly.

image

After that you should be able to Build project successfully. (If you haven’t other problems)

No Comments