Developing 2007 web parts on VS 2010


If you find yourself in a development environment consisting of the somewhat unlikely combination of MOSS and Visual Studio 2010, there is a simple way around a few things that will get in the way.

First, VS 2010 does not ship with a web part project template targeting MOSS because MS understandably wanted to maintain a consistent upgrade path from VS 2008 and the latter only had Workflow project templates. The Visual Web Part project template by itself is not terribly incompatible with MOSS, but VS 2010 requires that you have a SharePoint 2010 instance present in the environment you are using it in.

While it may be possible to hack your way around the root causes of this issue, there are a few simple ways to just get right down to work.

One such simple approach is to remember that web parts are a specialization of Server Controls.

Create a server control project targeting .NET 3.5 and either proceed to modify the class file stub created for you, or replace it with an old web part class file you have handy. Either way, you will need to make a few other minor tweaks to the project.

  1. Add the SharePoint DLL reference (obvious)
  2. Change the parent class you are inheriting from if starting from scratch
  3. Add a using statement to reference System.Security along with adding [assembly: AllowPartiallyTrustedCallers] to the AssemblyInfo.cs file
  4. Add your assembly signing key file (*.snk) to the project if you want VS to sign the assembly on build
  5. Add a *.DWP file is you go the WSS 2.0 route, but the ASP.NET web part approach of course negates the need for one of these if you GAC the assembly

That’s pretty much it. If you prefer the VSeWSS approach, there are posts out there on how to migrate these to VS 2010.

Advertisements

About generation12

I am a SharePoint/.NET consultant in the twin cities.
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s