Freigeben über


8. Upgrading SharePoint Site Definitions from v2 to v3 - UPGRADING YOUR WEB PARTS

The upgrade documentation implies that "most v2 web parts" will simply work in SharePoint v3. You can test your v2 web parts by adding them to a SharePoint v3 server and then dragging them one by one onto a page. 

None of the web parts I am dealing with fell into that class -- all had to be recompiled into .Net 2.0 -- and many required extensive modification due to deprecated classes in the SharePoint object model.

Note also that all of the web parts I am dealing with are installed in the GAC, and apparently the upgrade process treats web parts installed in the bin differently. If your web parts are installed in the bin then you have to redeploy them (use stsadm to AddWebPartPack) to the upgraded farm.

The main coding issues with my particular set of web parts were impersonation and Portal object model classes.

For a full list of SPS03 classes that have been deprecated, see:

https://msdn2.microsoft.com/en-us/library/ms545807.aspx

Otherwise just build your v2 web part projects in Visual Studio 2005 and the Error List will tell you exactly which of the classes in your web parts have been deprecated and have to be recoded.

If you used impersonation in your v2 web parts, then those web parts will fail under v3. You need to use SPSecurity.RunWithElevatedPriviledges as detailed here:

https://msdn2.microsoft.com/en-us/library/microsoft.sharepoint.spsecurity.runwithelevatedprivileges.aspx

Also note that although it makes sense to assign a new version number to your upgraded assemblies, going from version  1.0.0.0 to 2.0.0.0 for instance, but I suggest that it is simplest to recompile your v2 web parts in .Net 2.0 using the same version number, although this does make it difficult to tell the new assembly from the old one...

For info on how to add web parts into your custom Site Definition(s), see blog entry 9 "Creating The Site Definition".