Tags

,

One of the tricky bits with developing WebParts using Visual Studio 2005 is the deployment aspects.

As mentioned in this article, you firstly have to create a strong-name key, and compile the DLL, load the assembly into the GAC, and include as a SafeControl.

There are STSADM scripts that can be used to do the same thing or you need to load your dll into Web Part Gallery

With the release of Visual Studio 2008, you can use SmartTemplate and WSPBuilder (Both available in CodePlex).

It registers the DLL in the GAC, adds the feature (installfeature) and activates the feature (WSP) for each chosen Web Application.

When the wizard completes, just have to flip back to SharePoint to turn it on for each particular Site Collection :

* Site Settings > Site Collection features > Activate

The WebPart will then be available from the WebPart gallery, and can be added to a page.

This is a great time-saver – making deployment of WebParts much easier.

You also can use Deploy function to deploy the dll for quick test.

There is a good example to show you how to do it. http://www.aspfree.com/c/a/Windows-Scripting/Beginning-SharePoint-Web-Part-Development/1/

But the problem is if you redeploy you may get error:
“This solution contains two assemblies with the same name, or the SharePoint server already has an assembly with the specified name.” when deploying a solution using the Visual Studio Extensions for SharePoint (VSEWSS) after you have already deployed it to a different site on the same server.

Answer:

Remove the solution’s assembly from the Global Assembly Cache (GAC).

· Gacutil /uf assemblyName (note: no .dll extension is specified)

· Rename or Remove the feature from “Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES\FeatureName” (note: FeatureName may not be the same as assembly name – look in your manifest.xml to find the correct name)

If you deleted projects after you deploy the solution. You will get error as the manifest file still there.
Go to folder called pkg under your solution file folder and delete the folder which you have removed from solution

Advertisements