Creating Advanced Solutions for SharePoint 2007, Page 3
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
<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).
