Each assembly, whether static or dynamic, contains a set of data that describes how each element in the Assembly is associated with each other. The Assembly list contains the Assembly metadata. Assembly List includes
Specify the version requirements and all metadata required for the assembly, and define the scope of the Assembly and all metadata required for parsing references to resources and classes. The Assembly List can be stored in
PE files (.exe or. dll) with Microsoft intermediate language (msil) code can also be stored in independent PE files that only contain assembly list information.
For an assembly with an associated file, this list will be merged into the PE file to form a single file assembly. You can create an independent configuration file or merge the configuration into the same multi-file assembly.
Multi-file assembly of a PE file.
The list of each Assembly performs the following functions:
1. enumerate the files that constitute the assembly.
2. control how to map the type and resource reference of the Assembly to the file containing its declaration and implementation.
3. enumerate other assemblies on which the Assembly depends.
4. provide a certain degree of indirect information between the user of the Assembly and the user of the Implementation Details of the Assembly.
5. Present the Assembly self-report.
The assembly manifest content is described in XML file format, and the extension is (. manifest), for an application, we can associate the Assembly List to control the permission level to be run, and the style used when the execution program needs to run.
The following assembly manifest example requires administrator permissions for your program in Vista and win7, that is, the UAC Privilege Escalation dialog box is displayed when the program is running.
View code copy code print code about
- <? XML version = "1.0" encoding = "UTF-8" standalone = "yes"?>
- <Assembly xmlns = "urn: Schemas-Microsoft-com: ASM. V1" manifestversion = "1.0">
- <Assemblyidentity
- Version = "1.0.0.0"
- Processorarchitecture = "x86"
- Name = "test.exe. manifest"
- Type = "Win32"
- />
- <Trustinfo xmlns = "urn: Schemas-Microsoft-com: ASM. V3">
- <Security>
- <Requestedprivileges>
- <Requestedexecutionlevel level = "requireadministrator" UIAccess = "false"/>
- </Requestedprivileges>
- </Security>
- </Trustinfo>
- </Assembly>
If you want to change the Windows User Account Control level, replace the requestedexecutionlevel node with one of the following nodes.
View code copy code print code about
- <! -- General permission -->
- <Requestedexecutionlevel level = "asinvoker" UIAccess = "false"/>
- <! -- Administrator privilege -->
- <Requestedexecutionlevel level = "requireadministrator" UIAccess = "false"/>
- <! -- Maximum permission -->
- <Requestedexecutionlevel level = "highestavailable" UIAccess = "false"/>
Generally, there are two types of association: internal program embedding and external Association.
The procedure for embedding a program is as follows:
1. create an assembly manifest file named "your application name. manifest ". If your generated file is" test.exe ", the Assembly List (assembly manifest) is named" test.exe. manifest ".
2. select the newly created Assembly List (Assembly manifest.pdf file (test.exe. manifest), enter "rt_manifest" in the pop-up resource type dialog box, find the resource you just added, and change its ID attribute to 1. Of course, for internal embedding, the Assembly list file name, resource types and IDS can be customized.
3. recompile your program.
The external association method is as follows:
1. create an assembly manifest file named "your application name. manifest ". If your generated file is" test.exe ", the Assembly List (assembly manifest) is named" test.exe. manifest ".
2. Put "test.exe. manifest" in the same directory of your compiled "test.exe.
Note: If you use the internal program embedding method and the Assembly List defines that administrator permissions are required or the preceding permissions are required, the compiled program icons are marked with a small shield, and the external association does not display a small shield.
The following program configuration file allows your program to use WINXP controls:
View code copy code print code about
- <? XML version = "1.0" encoding = "UTF-8" standalone = "yes"?>
- <Assembly xmlns = "urn: Schemas-Microsoft-com: ASM. V1" manifestversion = "1.0">
- <Assemblyidentity
- Version = "1.0.0.0"
- Processorarchitecture = "x86"
- Name = "test.exe. manifest"
- Type = "Win32"
- />
- <Description> test application for XP style. </description>
- <Dependency>
- <Dependentassembly>
- <Assemblyidentity
- Type = "Win32"
- Name = "Microsoft. Windows. Common-Controls"
- Version = "6.0.0.0"
- Processorarchitecture = "x86"
- Publickeytoken = "6595b64144ccf1df"
- Language = "*"
- />
- </Dependentassembly>
- </Dependency>
- </Assembly>
It should be noted that the program runs XP and later systems, and the vc6 compilation that I tested can only use the internal program embedding method. Follow the steps described above, enter "24" (number only) in the imported resource type, find the added resource, and modify its ID attribute "1" (number only ). For vc7 and later versions, you can use external Association.
All of the above have been tested successfully in vc6 + win7!
The following describes how to use a program compiled by VC. Net to run the program on a computer without the. NET Framework installed. For example, run the program in the newly installed XP system. "the application fails to be started due to incorrect application configuration. Re-installing the application may correct this problem. . Use vs2008sp1 as
For example, we use the Wizard to generate a Common Dialog Box program (MFC application ).
1. choose Project Properties> manifest tool> input and output> embed manifest and select "no". In this way, the program list file is not automatically embedded during compilation, we use the external program inventory file for modification. Of course, there is a way to modify the internal program embedding.
2. Open "Vc \ redist \ x86 \ microsoft. vc90.crt" in the vs2008 installation directory, which contains four files: Microsoft. vc90.crt. manifest, msvcm90.dll, msvcp90.dll, and msvcr90.dll.
3. open the path "Vc \ redist \ x86 \ Microsoft. vc90.mfc ", which contains Microsoft. vc90.mfc. manifest, mfc90.dll, mfc90u. DLL, mfcm90.dll, and mfcm90u. DLL files.
4. Use notepad to open the Microsoft. vc90.crt. manifest file. You can find the version number "version = 9.0.30729.1" and write down the version numbers for backup.
5. generate the release version of your application, and use dependency Walker to view the dependent libraries. Here we should be "mfc90.dll" and "msvcr90.dll", and copy these two files and "Microsoft. vc90.crt. manifest "and" Microsoft. vc90.mfc. copy manifest to the same directory as the generated exe.
6. create "your application name" in the same directory as the application you generated. manifest "file. If your program is" test.exe ", the created file name is" test.exe. manifest ". Enter the following code (note that the version in the following code must be consistent with the version you noted down above ):
View code copy code print code about
- <? XML version = "1.0" encoding = "UTF-8" standalone = "yes"?>
- <Assembly xmlns = "urn: Schemas-Microsoft-com: ASM. V1" manifestversion = "1.0">
- <Dependency>
- <Dependentassembly>
- <Assemblyidentity type = "Win32" name = "Microsoft. vc90.crt" version = "9.0.30729.1"
- Processorarchitecture = "x86" publickeytoken = "1fc8b3b9a1e18e3b"> </assemblyidentity>
- </Dependentassembly>
- </Dependency>
- <Dependency>
- <Dependentassembly>
- <Assemblyidentity type = "Win32" name = "Microsoft. vc90.mfc" version = "9.0.30729.1"
- Processorarchitecture = "x86" publickeytoken = "1fc8b3b9a1e18e3b"> </assemblyidentity>
- </Dependentassembly>
- </Dependency>
- <Trustinfo xmlns = "urn: Schemas-Microsoft-com: ASM. V3">
- <Security>
- <Requestedprivileges>
- <Requestedexecutionlevel level = "asinvoker" UIAccess = "false">
- </Requestedexecutionlevel>
- </Requestedprivileges>
- </Security>
- </Trustinfo>
- </Assembly>
The above Runtime Library has passed the test in vs2008 SP1 and the new WINXP SP3