October 21, 2014
Hot Topics:
RSS RSS feed Download our iPhone app

Creating Advanced Solutions for SharePoint 2007

  • May 3, 2007
  • By Gustavo Velez
  • Send Email »
  • More Articles »

CodeAccessSecurity Element

The CodeAccessSecurity element characterizes the CAS policies for the Solution. The Element contains a chain of sub-elements:

<CodeAccessSecurity>
   <PolicyItem>
      <PermissionSet
         class = "Text"
         Description = "Text"
         Name = "Text"
         version = "Text">
      </PermissionSet>
      ...
      <Assemblies>
         <Assembly
            Name = "Text"
            PublicKeyBlob = "Text"
            Version = "Text">
         </Assembly>
      </Assemblies>
   </PolicyItem>
</CodeAccessSecurity>

The next example delineates a CAS policy, an aspect of the Full Trust standard CAS policy of SharePoint:

<CodeAccessSecurity>
   <PolicyItem>
      <PermissionSet
         class = "UnionCodeGroup"
         Description = "This code group grants code signed with
                        the Microsoft strong name full trust"
         Name = "Microsoft_Strong_Name"
         version = "1">
      </PermissionSet>
      <Assemblies>
         <Assembly
            Name = "System.Security.NamedPermissionSet"
            PublicKeyBlob = "00000000000000000400000000000000"
            Version = "1">
         </Assembly>
      </Assemblies>
   </PolicyItem>
</CodeAccessSecurity>

DwpFiles Element

As a final point, the recommended way of installing WebParts in SharePoint 2007 is via Solutions. The previous system in SharePoint 2003, applying CAB files and the "stsadm" administrator utility, is still supported, but principally to maintain the compatibility between the two versions. The syntax for the manifest file looks like this:

<DwpFiles>
   <DwpFile
      Location = "Text">
   </DwpFile>
   ...
</DwpFiles>
Caution: The Software Development Kit indicates the name of the parameter for the "DwpFile" subsection to be "FileName", but that is an error in the sporadically inaccurate SharePoint 2007 SDK. There are numerous syntax errors in the information about Solutions, so caution is advised as regards the information from the SDK.

It is important to consider that, in most working situations, a single element will rarely be used in a manifest for a Solution. For example, to install a WebPart, in addition to employing the "DwpFiles" component, the "Assemblies" element to install the DLL of the WebPart and the "SafeControls" element are needed to configurate it. And, if the WebPart uses resources files (icons, translations), you also will need the "Resources" component and the "CodeAccessSecurity" element to define the Security Police.

Consequently, a complete manifest solution file to install a WebPart may appear as:

<Solution SolutionId="4AFC1350-F354-4439-B941-51377E845ABC"
          xmlns="http://schemas.microsoft.com/sharepoint/">
<DwpFiles>
   <DwpFile Location = "MyLibrary.webpart"></DwpFile>
</DwpFiles>
   <Assemblies>
      <Assembly DeploymentTarget="WebApplication"
                Location="MyLibraryWebPart.dll">
         <SafeControls>
            <SafeControl
               Assembly="MyLibraryWebPart, Version=1.0.0.0,
                         Culture=neutral,
                         PublicKeyToken=6a50a9d627073d83"
               Namespace="MyLibraryWebPart"
               TypeName="*" Safe="True" />
         </SafeControls>
      </Assembly>
   </Assemblies>
   <ApplicationResourceFiles>
      <ApplicationResourceFile
         Location="pic.gif"/>
   </ApplicationResourceFiles>
</Solution>

In SharePoint 2007, it is possible to use traditional DWP files (.dwp) or the more current DotNet 2.0 WebPart definition files (.webpart).





Page 3 of 4



Comment and Contribute

 


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

 

 


Sitemap | Contact Us

Rocket Fuel