Remote WebPart Development for MOSS 2007

!! Absolutely no warranties, use at your own risk !!

I started to try the whole thing, because if you want to install the Windows SharePoint Services 3.0 Tools: Visual Studio 2005 Extensions on a Vista Machine it will fail:

So it is not possible to install the extension on a developer workstation. The official way to develop MOSS 2007 WebParts is to work on a Windows Server 2003 with at least WSS 3.0 installed or to use a similar VPC environment. In the VPC case this means you need to have at least 2 GB of memory available, in order to spend 1 – 1.5 GB for the Sharepoint Server VPC.

Setting up the Server or VPC Environment:

1. First of all you need a Windows Server 2003 machine or VPC, where MOSS 2007 is installed.
2. Install Visual Studio 2005 on the machine or VPC.
3. Install all Updates from Windows Update including Service Pack 1 for Team Suite or Service Pack 1 for Express Editions. If you run on Vista install the Service Pack 1 Update for Vista
4. Install WSS SDK, Office Server SDK and Visual Studio 2005 Extensions.

Setting up the Developer Workstation:

1. You need a Windows XP SP2 or Windows Vista Machine with Visual Studio 2005 installed.
2. Install all Updates from Windows Update including Service Pack 1 for Team Suite or Service Pack 1 for Express Editions. If you run on Vista install the Service Pack 1 Update for Vista
3. You can optionally install WSS SDK an Office Server SDK also on your Workstation
4. Locate the Sharepoint Templates installed on the server environment and copy them to your Workstation User Templates. You have to navigate to:
“C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\ProjectTemplates\CSharp”
and copy the whole Sharepoint Directory to your user Templates Folder on your Workstation. The Path is normally:
“C:\Users\<username>\Documents\Visual Studio 2005\Templates\ProjectTemplates\Visual C#”.
If you want to develop in VB.NET do the same for the Sharepoint Folder in:
“C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\ProjectTemplates\VisualBasic”
And copy it to:
“C:\Users\<username>\Documents\Visual Studio 2005\Templates\ProjectTemplates\Visual Basic”
Do the same for the Sharepoint Folders in the ItemTemplates Directory. There is only one for CSharp. Navigate to:
“C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\ItemTemplates\CSharp”
And copy the Sharepoint Folder to:
“C:\Users\<username>\Documents\Visual Studio 2005\Templates\ItemTemplates\Visual C#”
5. Copy the complete Folder “Microsoft Sharepoint Developer Tools”, which can be found in “C:\Program Files” on the Server or VPC to your Workstation machine in the same location.
6. In order to register the Projects, Packages and Templates on you Workstation machine you have to add several registry keys to your Registry. Here is the whole stuff, just copy and paste it in a text file and save it with a*.reg extension:

Windows Registry Editor Version 5.00
“CodeBase”=”C:\\Program Files\\Microsoft SharePoint Developer Tools\\package\\SPDevTools.dll”

“CodeBase”=”C:\\Program Files\\Microsoft SharePoint Developer Tools\\package\\SPDevTools.dll”

@=”Microsoft.SharePoint.Tools.SdtPackage, SPDevTools, Version=, Culture=neutral, PublicKeyToken=71E9BCE111E9429C”
“CodeBase”=”C:\\Program Files\\Microsoft SharePoint Developer Tools\\package\\SPDevTools.dll”
“ProductName”=”SharePoint Developer Tools”

“Path”=”C:\\Program Files\\Microsoft SharePoint Developer Tools\\package”

“DisplayProjectFileExtensions”=”SharePoint Project Files (*.csproj);*.csproj”


“TemplatesDir”=”C:\\Program Files\\Microsoft SharePoint Developer Tools\\package”

Double click the *.reg File or import it using Regedit. In order to load the new package file, you maybe must start Visual Studio from the command line with the option /ResetSkipPkgs. Start a Command Window (on Vista this should run as an administrator) and navigate to:

“C:\Progarm Files\Microsoft Visual Studio 8\Common7\IDE”

And start Visual Studio via the following command:

Devenv /ResetSkipPkgs

Now you should be able to create new Sharepoint Projects like WebParts. To doublecheck this, in Visual Studio 2005 navigate to the Menu File->New->Project the Dialog Box should look like this:

Now select the Web Part and click Ok. Visual Studio should create the appropriate Project Files. If you click on References in the Solution Explorer you will see that there is an unresolved reference to the “Microsoft.Sharepoint” Assembly. So you can not yet build the WebPart or other Sharepoint Projects on the Workstation. Therefore the next 2 steps are necessary.

7. The Sharepoint Assemblies (DLLs) are located in the following Folder on the Sharepoint Server Installation:

“C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\ISAPI”

I copied the complete folder to the same location on my Workstation, but you can also only copy the assemblies, which start with “Microsoft.Sharepoint.*” to any folder on your Workstation.

8. In order that Visual Studio can automatically resolve the references you should add the assemblies to the Global Assembly Cache” (GAC). You can use the command line tool gacutil.exe or use the “Microsoft .NET Framework 2.0 Configuration” which can be found through navigating to Control Panel, then select “Administrative Tools”.

9. Now you should be able to generate and build Sharepoint Server 2007 related projects on a remote Workstation.

Deploying the Webpart Assemblies to the Server machine or VPC:

There are several ways to deploy Webparts to MOSS 2007. But I describe one way, which makes it easy during the development cycle to deploy and remote debug Webparts on the Server or VPC. In the VPC case you should ensure that you have network connection to the running VPC image.
1. If you starting with a new project and you do not want to reduce MOSS Security to fully trust all installed assemblies. You should sign your WebPart with a strong name and add the following line to your “AssemblyInfo.cs” in your project:

[assembly: System.Security.AllowPartiallyTrustedCallers()]

2. After a successful build you should copy your WebPart Assemblies to the \bin directory of your MOSS 2007 Server. I do this by adding a post build step to the project:

Where <server> must be replaced with your server or VPC image name.
The post build step is configured to be executed “When the build updates the project output”.

3. The next step is to add a safe control entry to the web.config of the Server. This looks like:

<SafeControl Assembly=”MOSS2007_Test_WebPart, Version=, Culture=neutral, PublicKeyToken=b76147539a074d8d” Namespace=”MOSS2007_Test_WebPart” TypeName=”*” Safe=”True” />


The web.config is also located in the bin Directory:
in a default installation.

4. Navigate with the Browser to your target Site.
5. Click on Site Settings-> Modify all Site Settings
6. Click on Galleries -> Web Parts
7. Use the New Button to populate your Web Part to the gallery
I f your Web Part is not in the list, do an iisreset and try again. Normally the iisreset is not neccessary, but in some cases …
8. Now you can modify any page in your site and add you webpart to the page.

Now after a new successful build, the Web Part is copied to the server and is ready to be debugged.

Remote Debugging of Web Parts in MOSS 2007

1. In order to enable the Visual Studio remote debugging, navigate to “C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\Remote Debugger\x86” and start the “msvcmon.exe” on the server.
2. On the workstation in Visual Studio go to Debug -> Attach to process
3. In the Qualifier Text Box enter your server name
4. Check the Box: Show processes from all users.
5. Select *all* w3wp.exe processes using the control key on the keyboard
6. Click on Attach
7. Entry your breakpoints in the source code file in Visual Studio
8. Navigate or just refresh the Page, which has your control embedded and wait the breakpoint to be hit.

That’s it! Hope this procedures are somehow helpful to others, who want to develop Web Parts for MOSS 2007.

Comments (11)

  1. shawns says:

    It’s been difficult to find answers regarding developing webparts for WSS 3.0 from my development machine (which happens to be XP).  I haven’t gone through the process yet, but I thank you for taking the time to post this information.  It will be a huge help if it works!

    Why does Microsoft require development from a windows 2003 server?  Seems a little strange.

  2. Martin Vollmer hat sich die Mühe gemacht und einmal genau aufgeschrieben, wie man die Rechner zu konfigurieren

  3. vadimiron says:


    I have one problem: i can’t use some of the templates, why VS cannot import untrusted Microsoft.SharePoint.Tools.Wizards

    But where can i find this .dll?

    What should i do??

    The problem accures with "List Definition" and all elements ("Content Type", "Field Control" and so on)

  4. The Reactor says:

    When developing for SharePoint you may find the urge to install these tools from Microsoft. Windows SharePoint

  5. admoises says:

    It worked perfectly! One small thing to note, you should modify the policy configurations (wss_minimaltrust.config or wss_mediumtrust.config) to allow your dll’s to run under full trust policy.

  6. BradTravels says:

    I am receiving the following error why I go to create my Web Part project:

    "The project File: ‘c:Documents and Settings[username]Local SettingsTempgvohm3rc.j5zTempMyTasks.csproj’ cannot be opened.

    The project type is not supported by this installation.

    I followed steps 1 though 6 above exactly as they are laid out.

    I am using XP Pro SP2 with Visual Studio 2005 Standard Edition and have a working instance of SharePoint 3.0 and MOSS 2007 on a 2003 server. I have tried many of the suggestions that came up in Google to no avail, including running devenv /setup and re-registering the projectaggregator.dll

  7. Vollmix says:

    Ok, somebody else hat a similar Problem. Normally this error is a result of not having the right registry settings for the project type, or not having the right path settings in Visual Studio for the Project Templates. In order to get the right registry settings, you can try this:

    Go and save these 4 hives from your server installation:





    Maybe you have to replace the installation paths, keep an eye on that before replacing.

    And compare them to your hives on your workstation. If there are differences you can try to fix them manually or replace these for hives on your workstation. As I said be sure to save the original hives before.

    Hope this helps you too.

    Regards Martin

  8. coosa says:

    Is it possible to remote debug whereby the remote machine is on x64 while my machine is x86?

    Simply when choosing the processes (w3wp.exe) to attach, thier type will appear under WIN64; hence, I can’t attach them on my machine since it installed on 32-bit; but I just thought with a trick that it could be possible!

    Any suggestions

  9. manendra says:

    Hi,after creating a webpart project when i add a new webpart to my project is giving some error like

    "this template attemted to laod an untrusted component ‘Microsoft.sharepoint.Tolls.Wzard,version=,culture = Neutral

    PublicKeyToken=71E9BCE111E9429C’.For more information on this problem and how to enable this template,please see documentation on Customizing Project Templates."

    please help me in this…



  10. Cathy says:

    Hi, I could not find the folder "Microsoft Sharepoint Developer Tools" in "C:Program Files" on the sharepoint server. Which software should I install to get this folder?

    Please help. Thanks.

  11. Cathy says:

    Hi, I could not see web part when I click File -> New Project -> Sharepoint in my visual studio 2005 since I successfully installed visual studio 2005 extension for sharepoint v1.1 in my XP.

    Any idea?