The Application Manifest


When you compile an application, MSBuild produces the .exe file plus two manifest files: the application manifest, *.manifest, and a deployment manifest, *.deploy. You use these manifests when deploying an application or document from a server. First, copy the application, all of its dependencies, and the two manifest files to the appropriate location on your server. Second, edit the deployment manifest so that it points to the location of the application manifest.

For completeness, let s look at examples of the application and deployment manifests. The application manifest, shown in the following example, is actually not as interesting as the deployment manifest. The application manifest simply defines all the parts that make up an application. MSBuild produces the application manifest when it builds your application, and you typically modify little or nothing in it.

HelloWorld.manifest
start example
 <?xml version="1.0" encoding="utf-8"?> 
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"
xmlns:asmv2="urn:schemas-microsoft-com:asm.v2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:schemas-microsoft-com:asm.v1 assembly.adaptive.xsd">

<assemblyIdentity name="HelloWorld" version="1.0.0.0"
processorArchitecture="x86" asmv2:culture="en-us"
publicKeyToken="0000000000000000" />

<entryPoint name="main" xmlns="urn:schemas-microsoft-com:asm.v2"
dependencyName="HelloWorld">

<commandLine file="HelloWorld.exe" parameters="" />
</entryPoint>

<TrustInfo xmlns="urn:schemas-microsoft-com:asm.v2" xmlns:temp="temporary">
<Security>
<ApplicationRequestMinimum>
<PermissionSet class="System.Security.PermissionSet" version="1"
ID="SeeDefinition">
<IPermission
class="System.Security.Permissions.FileDialogPermission"
version="1" Unrestricted="true" />
<IPermission
class="System.Security.Permissions.IsolatedStorageFilePermission"
version="1" Allowed="DomainIsolationByUser" UserQuota="5242880" />
<IPermission
class="System.Security.Permissions.SecurityPermission"
version="1" Flags="Execution" />
<IPermission
class="System.Security.Permissions.UIPermission" version="1"
Window="SafeTopLevelWindows" Clipboard="OwnClipboard" />
<IPermission
class="System.Security.Permissions.PrintingPermission"
version="1" Level="SafePrinting" />
<IPermission
class="MSAvalon.Windows.AVTempUIPermission, PresentationFramework,
Version=6.0.4030.0, Culture=neutral,
PublicKeyToken=a29c01bbd4e39ac5" version="1"
NewWindow="LaunchNewWindows" FullScreen="SafeFullScreen" />
</PermissionSet>

<AssemblyRequest name="HelloWorld"
PermissionSetReference="SeeDefinition" />
</ApplicationRequestMinimum>
</Security>
</TrustInfo>

<dependency asmv2:name="HelloWorld">
<dependentAssembly>
<assemblyIdentity name="HelloWorld" version="0.0.0.0"
processorArchitecture="x86" />
</dependentAssembly>

<asmv2:installFrom codebase="HelloWorld.exe"
hash="5c58153494c16296d9cab877136c3f106785bfab"
hashalg="SHA1" size="5632" />
</dependency>
</assembly>
end example
 

Most of the contents of the application manifest should be relatively obvious. The entryPoint element specifies the name of the entry point method, main , and references the dependency , named HelloWorld , that contains the entry point. The entryPoint element also contains the program name and command-line argument that the shell will need to run the application.

The HelloWorld dependency element contains the information (the dependentAssembly element) that specifies the dependent assembly and an installFrom element that tells the loader where to find the assembly s file and the file s original hash. The loader can use the hash to detect changes made to the assembly subsequent to compilation.

The Longhorn Trust Manager uses the TrustInfo element to determine the security permissions that the application requires. In the previous example, my HelloWorld application defines a set of permissions it names the SeeDefinition permission set. Immediately after I define the set of permissions, the AssemblyRequest element requests that the assembly named HelloWorld receives at least the set of permissions in the set named SeeDefinition . The permissions in this example are the permissions normally granted to applications running in the SEE, so the Hello World application runs without displaying to the user any Trust Manager security warnings.




Introducing Microsoft WinFX
Introducing WinFX(TM) The Application Programming Interface for the Next Generation of Microsoft Windows Code Name Longhorn (Pro Developer)
ISBN: 0735620857
EAN: 2147483647
Year: 2004
Pages: 83
Authors: Brent Rector

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net