Recent posts

Speed up SharePoint Development by using some free tools

 

At the moment I’m doing a lot of SharePoint 2007 development and what I’m doing the most is waiting waiting …. So I tried to speed up SharePoint development in the project I’m currently working on. I will explain in a few steps how to create a solution for SharePoint the fastest way. In this example I use some SharePoint tools that you can download for free.

For this example I want to create a feature that when it is activated is changes the name of the site.

Create a C# class library and called “MySharePointSolution1” (delete the class1.cs file). It should look like this 

The structure that I’m creating is used by a very handy tool called the WSPBuilder. You can download this tool at http://www.codeplex.com/wspbuilder. In the documentation for this tool you can read what sort of a structure is desired for having the WSPbuilder working. I won’t explain that here.

 

You can see that I created some folders that mirror the structure of the structure of SharePoint, this must be done to have the WSPBuilder tool working. I added also the “SiteNameChangeFeature” folder which contains a feature receiver code to change the site name (we look at that later). I also added a post build event that copies the dll to the GAC folder inside the VS project.

copy "$(TargetPath)" "$(ProjectDir)GAC"

The “solution” folder that I is created contains the actual solutions package for SharePoint, the “.wsp” file.

The “feature.xml” looks like this

<?xml version="1.0" encoding="utf-8" ?>

<Feature Id="6395B135-6552-45bc-A842-58900C1E553E"

Title="Site name change feature"

Description="This feature will change the name of the site"

Version="1.0.0.0"

Scope ="Web"

Hidden="false"

xmlns="http://schemas.microsoft.com/sharepoint/"

ReceiverAssembly="MySharePointSolution1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=403f4a28f90a5cfd"

ReceiverClass="MySharePointSolution1.SiteNameChangeEventFeatureHandler">

</Feature>

The “SiteNameChangeFeatureHandler.cs” looks like this

using Microsoft.SharePoint;

namespace MySharePointSolution1

{

public class SiteNameChangeEventFeatureHandler : SPFeatureReceiver

{

public override void FeatureActivated(SPFeatureReceiverProperties properties)

{

object featureParent = properties.Feature.Parent;

SPWeb site = (SPWeb) featureParent;

site.Title = "A New Title";

site.Update();

site.Dispose();

}

public override void FeatureDeactivating(SPFeatureReceiverProperties properties)

{

return;

}

public override void FeatureInstalled(SPFeatureReceiverProperties properties)

{

return;

}

public override void FeatureUninstalling(SPFeatureReceiverProperties properties)

{

return;

}

}

Try to build the project and the “MySharePointSolution1.dll” should appear in the GAC folder in your VS project.

Next step is to add the “WSPBuilder.exe”, “CabLib.dll” (comes with the WSPBuilder) to your VS project and add another post build event .

$(ProjectDir)wspbuilder.exe -Outputpath "$(ProjectDir)solution" -WSPName "MySharePointSolution1_v0.1.wsp"

Rebuild the project. If everything went ok then the “solution” folder should now contain a “manifest.xml” and a “MySharePointSolution1_v0.1.wsp” (press “show all files in the solutions explorer”).

The next step is to install the created wsp file into our SharePoint environment. We could use the “stsadm.exe” command line utility for this but I’m using another tool for that, the “SharePoint Solultion Installer”. You can download this tool and read the usage of this tool at http://blog.mondosoft.com/ontolica/archive/2007/03/14/Generic-SharePoint-2007-Solution-Installer.aspx . When you extract the SharePointSolutionInstaller_V1_0_3.zip you get a “setup.exe” and a “setup.exe.config”. Put these two files in the “solution” folder of the VS project.

The total solution should look something like this now

 

Modify the “setup.exe.config” with the correct solution id and title. Mine looks like this. (Your solution id is probably different. You can find your solution id in the generated “manifest.xml” or in a file called “solution.txt” in the root of the vs. project)

<?xml version="1.0" encoding="utf-8" ?>

<configuration>

<appSettings>

<add key="BannerImage" value="Default"/>

<add key="LogoImage" value="None"/>

<add key="EULA" value=""/>

<add key="Require" value="MOSS"/>

<add key="SolutionId" value="93f0038b-94ec-40ef-b628-cda46bb4b5cc"/>

<add key="FarmFeatureId" value=""/>

<add key="SolutionFile" value="MySharePointSolution1_v0.1.wsp"/>

<add key="SolutionTitle" value="MySharePointSolution1"/>

<add key="SolutionVersion" value="1.0.0.0"/>

<add key="UpgradeDescription" value="Upgrades {SolutionTitle} on all frontend web servers in the SharePoint farm."/>

<add key="RequireDeploymentToCentralAdminWebApllication" value="true"/>

<add key="RequireDeploymentToAllContentWebApplications" value="false"/>

</appSettings>

</configuration>

Now you can run the setup.exe and install the solution in SharePoint. If everything went ok you should see your feature in the “site features” list.

 

The conclusion is that by using the “WSPBuilder” you get the advantage of not creating a “ddf” file and a “manifest.xml” . And by using the “SharePoint Solution Installer” tool you don’t have to use the stsadm.exe command line to install your solution in SharePoint.

One last thing you can do is add the following line to the post build event so that your new compiled dll is deployed directly to the “real” GAC.

"c:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin\gacutil.exe" -if "$(TargetPath)"

I use another tool called the “application pool manager” you can download at http://www.harbar.net/archive/2007/04/06/App-Pool-Recycler-for-SharePoint-devs.aspx to not do a “iisreset” but only recycle the application pool, which makes the SharePoint development a bit faster.

The latest articles I read about SharePoint development are:

Development Tools and Techniques for Working with Code in Windows SharePoint Services 3.0 (Part 1 of 2)

http://msdn2.microsoft.com/en-us/library/bb530302.aspx

Development Tools and Techniques for Working with Code in Windows SharePoint Services 3.0 (Part 2 of 2)

http://msdn2.microsoft.com/en-us/library/bb530301.aspx


Published: 26-06-2007 by Rene Jansen | 0 Comments | 0 Links to this post
 

Debugging InfoPath 2007 forms in MOSS 2007 Forms Services

Finally! If you are lucky enough to work with InfoPath 2007 and MOSS 2007 Forms Services then you probably also noticed that "Code Behind the Form" does not always run in the same smooth way it runs in the Smart Client (InfoPath 2007 Forms Preview). But what is really happening behind the scenes? Now, you can find out. You can read the following article over and over: http://msdn2.microsoft.com/en-us/library/aa944831(VS.80).aspx, but it doesn't really do the trick. After carefully following the output of attaching the debugger to the w3wp processes I noticed that it won't load your code-behind DLL, because it is "Optimized". Once you uncheck this debugging option you are in the debugging party. The complete recipe:

  • Start VSTOS 2005 and set the Debug Info to full in the advanced debugging Build options. Also uncheck the "Optimized" option. Publish your form. Inside the XSN file the manifest.xsf file will change and the PDB will also be part of the file now.
  • Upload the form to Central Administration and activate to the site if needed
  • Open the form in the site.
  • Start the regular VS 2005 and attach the debugger to all running w3wp processes. Load the source file that was used to build the code-behind DLL. Set breakpoints and notice they actually will break!

Have fun being twice as productive!


Published: 20-06-2007 by Wim The | 0 Comments | 0 Links to this post
 

Having fun while doing my job

Recently, I've been giving presentations on topics such as C# 2.0 and ASP.NET 2.0 to some of the coworkers of Aviva .NET Professionals (a partner of Aviva Solutions). Usually that is not something worth blogging about. But yesterday evening's group was so full of enthousiasme, I couldn't resist sharing the enjoyment that I had while driving home. The picture is a bit blurry (and the powercable of the beamer is clearly visible), but you should be able to see the grin on my face (the guy with the blue-and-red shirt).
 

 

Published: 13-06-2007 by Dennis Doomen | 0 Comments | 0 Links to this post
 

Single Sign On

I was configuring a website for a customer with single sign on using forms authentication, the previous configurations used resulted in unreliable sign on.
 
So I found the following excellent blogpost describing the steps needed to use single sign on using forms authentication. http://weblogs.asp.net/hernandl/archive/2004/06/09/ssoformsauth.aspx
 
It seemed that the trick was in the machinekey element.
 
So i found another site to create the appropriate key for me:
 
Like they say in Dutch "Doe er je voordeel mee!"
 
See also:
 
Hope this helps!
 
 
 

Published: 13-06-2007 by Frans Bruijnen | 0 Comments | 0 Links to this post
 

Visual Studio 'Orcas'...2007...2008

If you have been reading the many posts about this week's TechED that is going on in Orlando, you may have noticed the references to Visual Studio 2008 (a.k.a.) and SQL Server 2008 (a.k.a. Katmai). I'm not sure if I've been been paying attention or not, but I don't remember any formal announcement on this name-change. In fact, the April CTP still mentioned Visual Studio 2007 in its setup. Nonetheless, it does fit nicely in the pattern that has been used for all editions of Visual Studio.

June 6 Update: It is now official...see here.

June 7 Update: There is FAQ explaining how Visual Studio 2005 and 2008 co-exist with eachother.


Published: 05-06-2007 by Dennis Doomen | 0 Comments | 0 Links to this post