Login | Register   
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

Using SharePoint Solutions to Deliver Server-Side Solutions : Page 3

Discover an elegant technique for creating and deploying solutions that provide reusable processes for installing and uninstalling custom code.


advertisement
Embedding CAS Policies
The final objective for the manifest.xml file is to deploy the web part, which is done in two pieces: deploying the assembly and deploying the .webpart template file that users employ to add the web part to a page. You can deploy the assembly with an <Assembly> node under the <Assemblies> node. The <Assembly> tag has two attributes:
  • DeploymentTarget – This attribute specifies where the assembly (DLL) will be copied to. The WebApplication option makes a copy of the file in the bin directory of the web application. This mechanism means that the file will not be trusted fully and will be subject to CAS policies. The other value, GlobalAssemblyCache, does deploy the assembly to the GAC, which means it will be trusted fully and thus not subject to CAS policies. Note that the use of the GlobalAssemblyCache attribute will require that the user doing the deployment explicitly allows GAC deployment.
  • Location – As with the tags previously discussed, the Location attribute provides the location of the assembly file in the solution file.
Although it's not demonstrated here, it's possible to embed CAS policies in the solution file. During deployment the solutions framework will add these CAS policies to the existing policy file. The fact that the solution framework does this manipulation during deployment is a great advance over previous deployment scenarios. It doesn't require that administrators keep a master CAS policy or manually manipulate the XML files themselves.

In the case of web part assemblies, like the WFInspectorWebParts assembly that contains the web part for this example, you also need a <SafeControls> node containing one or more <SafeControl> nodes in the manifest.xml file and irrespective of whether a CAS policy is used or the assembly is deployed to the GAC. These <SafeControl> entries will be copied to the web.config of the application during the deployment process. Just like the <SafeControl> entry in web.config, the <SafeControl> element contains these four attributes:

  • Assembly – This attribute is the fully specified assembly name that includes name, version, culture, and public key token.
  • Namespace – This attribute is the namespace to which the web part or web parts belong.
  • TypeName – This attribute is the name of the web part class—or more commonly, *, indicating that all classes in the namespace should be considered safe.
  • Safe – This attribute must contain TRUE for the <SafeControl> entry to be considered.
In putting the web part assemblies together, you can deploy the XML fragment for deploying the assembly this way:

<Assemblies> <Assembly DeploymentTarget="WebApplication" Location= "WFInspectorWebParts.dll"> <SafeControls> <SafeControl Assembly="WFInspectorWebParts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=42c55593c85ca4ad" Namespace="WFInspectorWebParts" TypeName="*" Safe="True"/> </SafeControls> </Assembly> </Assemblies>

Now it's time to direct SharePoint how to deploy the .webpart file, and then users can add the WFInspectorWebParts web part themselves, if they want to. They can add the web part with the <DwpFiles> and <DwpFile> set of tags. The <DwpFile> tag contains a single attribute: Location. It indicates the location of the file in the solution file. The "Dwp" part of the name is a holdover from previous versions of the product and was the extension used for web parts prior to SharePoint 3.0.



The whole manifest.xml file looks like this:

<?xml version="1.0" encoding="utf-8" ?> <Solution SolutionId="6C692C86-35FE-4967-8A6E-BACD9AB10423" DeploymentServerType="WebFrontEnd" ResetWebServer="TRUE" xmlns="http://schemas.microsoft.com/sharepoint/"> <FeatureManifests> <FeatureManifest Location="WFInspector\feature.xml" /> <FeatureManifest Location="WFInspectorStaple\feature.xml"/> </FeatureManifests> <TemplateFiles> <TemplateFile Location="FEATURES\WFInspector\default.aspx"/> </TemplateFiles> <Assemblies> <Assembly DeploymentTarget="WebApplication" Location="WFInspectorWebParts.dll"> <SafeControls> <SafeControl Assembly="WFInspectorWebParts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=42c55593c85ca4ad" Namespace="WFInspectorWebParts" TypeName="*" Safe="True"/> </SafeControls> </Assembly> </Assemblies> <DwpFiles> <DwpFile FileName="WFInspectorWebParts.webpart" Location="WFInspectorWebParts.webpart" /> </DwpFiles> </Solution>



Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap