Visual Studio 2005 Extensions for WSS

Let's take a quick look at what these extensions can do for you. As you can expect from me I'm only interesting in the Web Part section of this product. For all other options check out this blog called Walkthrough - Windows SharePoint Services 3.0 Tools: Visual Studio 2005 Extensions. About handling Web Parts, Mart Muller wrote an excellent blog about how you Create a SharePoint 2007 webpart step by step. With the new extensions you only have be aware of the steps Mart wrote, but you don't have to execute those anymore.

After installing the product you have the ability to select a Web Part project from the SharePoint project types. Web Parts were first introduced in Windows SharePoint Services v2. The concept was so compelling that the model was improved and added to the second generation of ASP.NET: ASP.NET 2.0. This wasn't the only addition to ASP.NET 2.0. Other improvements and enhancements allowed the Windows SharePoint Services team to revamp their underlying architecture that resulted in it being rebuilt on top of ASP.NET 2.0 (previously, WSS v2 had it's own rendering engine).


After selecting this project, it will create a base project with a template file as shown below. As you can see it will inherit from the ASP.NET 2.0 WebPart class (System.Web.UI.WebControls.WebParts.WebPart), but you can also build Web Parts that inherit the WSS v3 WebPart class (Microsoft.SharePoint.WebPartPages.WebPart). To decide from which Web Part you should derive check Creating Web Parts in Windows SharePoint Services. In most cases you could stick to default settings. As we can expect from a custom control we do need to set it's rendering. After doing so, check you settings of the project.

    1 using System;

    2 using System.Runtime.InteropServices;

    3 using System.Web.UI;

    4 using System.Web.UI.WebControls.WebParts;

    5 using System.Xml.Serialization;


    7 using Microsoft.SharePoint;

    8 using Microsoft.SharePoint.WebControls;

    9 using Microsoft.SharePoint.WebPartPages;


   11 namespace My_First_Extension_Web_Part

   12 {

   13     [Guid("e17149f4-56e6-4c5d-909c-3cec0a1d0f27")]

   14     public class My_First_Extension_Web_Part : System.Web.UI.WebControls.WebParts.WebPart

   15     {

   16         public My_First_Extension_Web_Part()

   17         {

   18             this.ExportMode = WebPartExportMode.All;

   19         }


   21         protected override void Render(HtmlTextWriter writer)

   22         {

   23             // TODO: add custom rendering code here.

   24             writer.Write("My First Extensions Web Part!");

   25         }

   26     }

   27 }

The extensions introduced a new Tab for a SharePoint Solution. In this tab you can set the settings for its solution, the feature and even the element itself. This will give you the ability to easilly set these settings without creating additional files. Besides this extra tab, the project will also sign this assembly with a strong name key, so it can be easily added to the GAC. Note: This key is for every newly created project on the same machine identical.

In the next screen dump you can see the project is deployed to the web server, which contains SharePoint. It will create a *.wsp file, which will automatically add the Web Part to the GAC, mark your Web Part as safe in the web.config of the SharePoint site, populate your Web Part gallery and reset its server.  

------ Build started: Project: My First Extension Web Part, Configuration: Debug Any CPU ------

C:WINDOWSMicrosoft.NETFrameworkv2.0.50727Csc.exe /noconfig /nowarn:1701,1702 /errorreport:prompt /warn:4 /define:DEBUG;TRACE /reference:"C:Program FilesCommon FilesMicrosoft SharedWeb Server Extensions12ISAPIMicrosoft.SharePoint.dll" /reference:C:WINDOWSMicrosoft.NETFrameworkv2.0.50727System.dll /reference:C:WINDOWSMicrosoft.NETFrameworkv2.0.50727System.Web.dll /reference:C:WINDOWSMicrosoft.NETFrameworkv2.0.50727System.Xml.dll /debug+ /debug:full /keyfile:PropertiesTemporary.snk /optimize- /out:"objDebugMy First Extension Web Part.dll" /target:library PropertiesAssemblyInfo.cs "My First Extension Web PartMy First Extension Web Part.cs"


Compile complete -- 0 errors, 0 warnings

My First Extension Web Part -> D:ProjectsWebPartsMy First Extension Web PartbinDebugMy First Extension Web Part.dll

------ Deploy started: Project: My First Extension Web Part, Configuration: Debug Any CPU ------

------ Generate My First Extension Web Part.wsp file and setup batch file------

Creating solution ...

Operation completed successfully.


Creating setup batch file ...

Operation completed successfully.


------ Add and deploy My First Extension Web Part.wsp to the SharePoint ------

Adding solution ...

Operation completed successfully.


Deploying solution ...

Operation completed successfully.


------ Activate features in solution if necessary ------

Activating feature My_First_Extension_Web_Part ...

Operation completed successfully.


Restarting IIS ...

 After deploying you can add your newly created web part to your SharePoint site like you've done thousands of times before.

It's good to have these new extensions for Web Parts. Offcourse you still have to know the steps mentioned by Mart, but you don't have to follow them exactly anymore. I personally think it's a great effort of the SharePoint team and like to thanks you guys.


2 thoughts on “Visual Studio 2005 Extensions for WSS

  1. Darryl

    How can I do the following using vs2005:

    for a document library using sharepoint 2007

    1. Total Number of files, total aggregate disk space used (all versions)
    2. Total Number of files, total aggregate disk space used (latest version)
    3. Number of files modified in the last hour
    4. Number of files modified in the last day
    5. Number of files modified in the last week
    6. Total number of files with multiple versions
    7. Number of files currently checked out/in

  2. Harsha Narahari

    This is very useful (WSS extentions).
    But any way we can achieve it from client machine?
    Have tried it and get error:
    "Could not load file or assembly 'Microsoft.SharePoint.Security, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c' or one of its dependencies. The system cannot find the file specified."


Leave a Reply

Your email address will not be published. Required fields are marked *