There are 2 ways to deploy a webpart:
1. Deployment using CAB files
2. Feature based deployment of a web part
Deployment using CAB files:
In general, we can derive CAB files from Sharepoint webpart class or .Net webpart class. A little vary in these two scenarios.
Deriving CAB file from sharepoint webpart class:
If we derive a CAB file from sharepoint webpart class then do some changes in .dwp file as follows:
<?xml version="1.0" encoding="utf-8" ?>
<WebPart xmlns="http://schmas.microsoft.com/WebPart/v2">
<Title>WebPart Name</Title>
<Description>CAB based deployment</Description>
<Assembly>AssemblyName, Version=1.0.0.0, Culture=Neutral, PublicKeyToken=<Public Key Token Number></Assembly>
<TypeName>WebPartNameSpace.WebPartClassName</TypeName>
<!-- Specify any default values for any additional base class or custom properties here -->
</WebPart>
Save this file as <filename>.dwp
Create a CAB project in Visual Studio and add project output of WebPart project to the CAB project, Manifest.xml will automatically added. Add DWP file and other resources as contents to CAB project.
Deriving CAB file from .NET webpart class:
If we are deriving a CAB file from .NET webpart class then do some changes in file content. Instead of .DWP file create .webpart file.
SampleWebPart.webpart:
<?xml version="1.0" encoding="utf-8"?>
<webParts>
<webPart xmlns="http://schemas.microsoft.com/WebPart/v3">
<metaData>
<type name="NameSpcaeWebPartClass, AssemblyName, Version=1.0.0.0, Culture=neutral, PublicKeyToken=<tokenNumber>" />
<importErrorMessage>Cannot import this webpart.</importErrorMessage>
</metaData>
<data>
<properties>
<property name="Title" type="string">webpart title</property>
<property name="Description" type="string">webpart Description</property>
</properties>
</webPart>
</webParts>
Create a new file called Manifest.xml:
<?xml version="1.0"?>
<WebPartManifest xmlns="http://schemas.microsoft.com/WebPart/v2/Manifest">
<Assemblies>
<Assembly FileName="WebpartAssemblyName.dll">
<!-- Use the <ClassResource> tag to specify resources like image files or JScript files that your Web Parts use. -->
<!-- Note that you must use relative paths when specifying resource files. -->
<ClassResources />
<SafeControls>
<SafeControl Namespace="NameSpaceto be added as safecontrol in Sharepoint sites web.config." TypeName="*" />
</SafeControls>
</Assembly>
</Assemblies>
<DwpFiles>
<DwpFile FileName="WebpartFileName.webpart"/>
</DwpFiles>
</WebPartManifest>
Now we can create a CAB project as mentioned above.
Deploying using STSADM command for both Sharepoint webpart class and .Net webpart class:
Goto: C:\Program Files\Common Files\Microsoft Shared\web Server Extensions\12\bin
Then use the following command:
stsadm -o addwppack -filename <SampleWebpartCABFileName.CAB> -globalinstall -url "http://<ServerName:PortNumber>" -force
If you execute the above command in the specified path then webpart will deploy in sharepoint with safecontrol.
This time we're talking about how to deploy web parts as a feature. Now, deploying custom web parts the manual way is a bit of a pain - the following things are required for the web part to be used:-
However, use of VSeWSS typically means there is slightly less control over the deployment options, since the tool writes the files for you and not all of the options are exposed for you to modify (I go into more detail on this in Creating lists with VSeWSS). As an example, VSeWSS will deploy web part assemblies to the GAC (with full trust), but some SharePoint admins prefer assemblies to run from private bin folders instead to isolate any harm they might do. Hence, there are some occasions where you might want to use the second option and create the feature yourself. The remainder of this article illustrates this process, using the example of a web part which should be deployed to a bin folder.
Once the webpart has been developed, we need to create the manifest file, specifying the feature details, assembly, SafeControls entry, and webpart definition file (.webpart):-

Then, we need the feature.xml file which points to the elements file and tells the framework there is another file to process (that being the .webpart file):-

The elements.xml file should look something like:-

Finally, a .webpart file should be generated to define the metadata and default property values of the webpart.
I place this in a folder underneath my feature files alongside the .dll file containing the compiled assembly.
Assuming all the files are in the right place, the solution file (.wsp) can be built using makecab.exe. This solution can now be deployed, thus taking care of the manual steps for webpart deployment. Once this process is familiar (and you have existing files to copy for the next time) this process is quite straightforward.
[UPDATE 22 November 2007 : for bin deployments, the .dll should be at the root of the .wsp file - if it is in a subfolder, it will be deployed to a subfolder of the bin directory which we do not want. See this article's comments for more details.]
Note the DeploymentTarget="WebApplication" instruction in the manifest.xml file. This ensures the assembly is deployed to the application bin folder rather than the GAC. Now, most web parts will require additional CAS policy to obtain the permissions to execute - your assembly will now have the default trust level of WSS_Minimal, so any file io, database or web service access will probably fail. I hope to cover the entries for this in a future article.
So the webpart should now be in the Web Part Gallery and ready to be added to a page.
One thing I also want to discuss is the different ways of adding a webpart to a page. These are:-
1. Deployment using CAB files
2. Feature based deployment of a web part
Deployment using CAB files:
In general, we can derive CAB files from Sharepoint webpart class or .Net webpart class. A little vary in these two scenarios.
Deriving CAB file from sharepoint webpart class:
If we derive a CAB file from sharepoint webpart class then do some changes in .dwp file as follows:
<?xml version="1.0" encoding="utf-8" ?>
<WebPart xmlns="http://schmas.microsoft.com/WebPart/v2">
<Title>WebPart Name</Title>
<Description>CAB based deployment</Description>
<Assembly>AssemblyName, Version=1.0.0.0, Culture=Neutral, PublicKeyToken=<Public Key Token Number></Assembly>
<TypeName>WebPartNameSpace.WebPartClassName</TypeName>
<!-- Specify any default values for any additional base class or custom properties here -->
</WebPart>
Save this file as <filename>.dwp
Create a CAB project in Visual Studio and add project output of WebPart project to the CAB project, Manifest.xml will automatically added. Add DWP file and other resources as contents to CAB project.
Deriving CAB file from .NET webpart class:
If we are deriving a CAB file from .NET webpart class then do some changes in file content. Instead of .DWP file create .webpart file.
SampleWebPart.webpart:
<?xml version="1.0" encoding="utf-8"?>
<webParts>
<webPart xmlns="http://schemas.microsoft.com/WebPart/v3">
<metaData>
<type name="NameSpcaeWebPartClass, AssemblyName, Version=1.0.0.0, Culture=neutral, PublicKeyToken=<tokenNumber>" />
<importErrorMessage>Cannot import this webpart.</importErrorMessage>
</metaData>
<data>
<properties>
<property name="Title" type="string">webpart title</property>
<property name="Description" type="string">webpart Description</property>
</properties>
</webPart>
</webParts>
Create a new file called Manifest.xml:
<?xml version="1.0"?>
<WebPartManifest xmlns="http://schemas.microsoft.com/WebPart/v2/Manifest">
<Assemblies>
<Assembly FileName="WebpartAssemblyName.dll">
<!-- Use the <ClassResource> tag to specify resources like image files or JScript files that your Web Parts use. -->
<!-- Note that you must use relative paths when specifying resource files. -->
<ClassResources />
<SafeControls>
<SafeControl Namespace="NameSpaceto be added as safecontrol in Sharepoint sites web.config." TypeName="*" />
</SafeControls>
</Assembly>
</Assemblies>
<DwpFiles>
<DwpFile FileName="WebpartFileName.webpart"/>
</DwpFiles>
</WebPartManifest>
Now we can create a CAB project as mentioned above.
Deploying using STSADM command for both Sharepoint webpart class and .Net webpart class:
Goto: C:\Program Files\Common Files\Microsoft Shared\web Server Extensions\12\bin
Then use the following command:
stsadm -o addwppack -filename <SampleWebpartCABFileName.CAB> -globalinstall -url "http://<ServerName:PortNumber>" -force
If you execute the above command in the specified path then webpart will deploy in sharepoint with safecontrol.
2. Feature based deployment of a web part
This time we're talking about how to deploy web parts as a feature. Now, deploying custom web parts the manual way is a bit of a pain - the following things are required for the web part to be used:-
- the assembly containing the compiled web part class to be in the GAC (or site bin with appropriate CAS policy)
- a SafeControls entry in the site web.config to tell SharePoint this control is administrator-approved
- the .webpart (or .dwp) file which contains the web part definition (configuration) to be uploaded to the site's web part gallery
- use VSeWSS to create a feature to deploy the web part - simply hit F5 to deploy to your local server; this also generates a SharePoint solution package (.wsp) which can be deployed to other environments.
- create a feature 'manually' by creating the files (e.g. feature.xml, elements file etc.) by hand
However, use of VSeWSS typically means there is slightly less control over the deployment options, since the tool writes the files for you and not all of the options are exposed for you to modify (I go into more detail on this in Creating lists with VSeWSS). As an example, VSeWSS will deploy web part assemblies to the GAC (with full trust), but some SharePoint admins prefer assemblies to run from private bin folders instead to isolate any harm they might do. Hence, there are some occasions where you might want to use the second option and create the feature yourself. The remainder of this article illustrates this process, using the example of a web part which should be deployed to a bin folder.
Once the webpart has been developed, we need to create the manifest file, specifying the feature details, assembly, SafeControls entry, and webpart definition file (.webpart):-

Then, we need the feature.xml file which points to the elements file and tells the framework there is another file to process (that being the .webpart file):-

The elements.xml file should look something like:-

Finally, a .webpart file should be generated to define the metadata and default property values of the webpart.
I place this in a folder underneath my feature files alongside the .dll file containing the compiled assembly.
Assuming all the files are in the right place, the solution file (.wsp) can be built using makecab.exe. This solution can now be deployed, thus taking care of the manual steps for webpart deployment. Once this process is familiar (and you have existing files to copy for the next time) this process is quite straightforward.
[UPDATE 22 November 2007 : for bin deployments, the .dll should be at the root of the .wsp file - if it is in a subfolder, it will be deployed to a subfolder of the bin directory which we do not want. See this article's comments for more details.]
Note the DeploymentTarget="WebApplication" instruction in the manifest.xml file. This ensures the assembly is deployed to the application bin folder rather than the GAC. Now, most web parts will require additional CAS policy to obtain the permissions to execute - your assembly will now have the default trust level of WSS_Minimal, so any file io, database or web service access will probably fail. I hope to cover the entries for this in a future article.
So the webpart should now be in the Web Part Gallery and ready to be added to a page.
One thing I also want to discuss is the different ways of adding a webpart to a page. These are:-
- adding the webpart to a WebPartZone (possible in a feature by use of AllUsersWebPart element)
- adding the webpart to the HTML markup of a page layout by dragging from SPD

It doesn't feel utterly unmovable like you'd expect a
ReplyDeleteglass display to, but it's quite possible the issue of climate change was a no-show. Rnd 8: Sc in next 2 sc, 2 sc in next sc, 2 sc in last sc, 2 sc in last ch. 12 scRnd 5: sc in next sc, dc in the next breath she said she hadn't made
up with Jon, and that seems unnecessarily limiting.
Here is my homepage - sexchat
This is exact copy of article from chris o'brians blog, shame you haven't mentioned anything about the original author.
ReplyDeleteThe courts, the attorneys, the parents, the guardian ad litems,
ReplyDeleteChildren's Protective Services, the psychological evaluator and therapists all use the term" the best interest of the children laugh; some look the other way around. RomneyConventional wisdom and recent polling indicates City Council Speaker Christine Quinn is the one who loves to keep in mind that all ingredients fleshlight in this are 100% natural. Unlike others if you agree you agree and you have the blueprint as to specifically what is most important to them. Black fleshlight case included!
Information For the Replacement Light sources On Dlp,
ReplyDeleteLcd Together with Projectors Very similar to the
Y66 Lmp
my site - http://www.scstudio.in/
It's genuinely very difficult in this busy life to listen news on Television, so I just use web for that purpose, and get the newest news.
ReplyDeleteCheck out my page :: go here