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.
- Add the SharePoint DLL reference (obvious)
- Change the parent class you are inheriting from if starting from scratch
- Add a using statement to reference System.Security along with adding [assembly: AllowPartiallyTrustedCallers] to the AssemblyInfo.cs file
- Add your assembly signing key file (*.snk) to the project if you want VS to sign the assembly on build
- 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.