程序集清单文件

179 篇文章 0 订阅
86 篇文章 0 订阅

https://msdn.microsoft.com/zh-cn/library/aa374219(v=vs.85).aspx



Assembly Manifests

An assembly manifest is an XML file that describes a side-by-side assembly. Assembly manifests describe the names and versions of side-by-side assemblies, files, and resources of the assembly, as well as the dependence of the assembly on other side-by-side assemblies. Correct installation, activation, and execution of side-by-side assemblies requires that the assembly manifest always accompany an assembly on the system.

For a complete listing of the XML schema, see Manifest File Schema.

Assembly manifests have the following elements and attributes.

ElementAttributesRequired
assembly Yes
 manifestVersionYes
noInheritable No
assemblyIdentity Yes
 typeYes
 nameYes
 languageNo
 processorArchitectureNo
 versionYes
 publicKeyTokenNo
dependency No
dependentAssembly No
file No
 nameYes
 hashalgNo
 hashNo
comClass No
 descriptionNo
 clsidYes
 threadingModelNo
 tlbidNo
 progidNo
 miscStatusNo
 miscStatusIconNo
 miscStatusContentNo
 miscStatusDocPrintNo
 miscStatusDocPrintNo
typelib No
 tlbidYes
 versionYes
 helpdirYes
 resourceidNo
 flagsNo
comInterfaceExternalProxyStub No
 iidYes
 baseInterfaceNo
 numMethodsNo
 nameNo
 tlbidNo
 proxyStubClsid32No
comInterfaceProxyStub No
 iidYes
 nameYes
 tlbidNo
 baseInterfaceNo
 numMethodsNo
 proxyStubClsid32No
 threadingModelNo
windowClass No
 versionedNo

 

File Location

Assembly manifests can be installed in three locations:

  • As manifests that accompany shared assemblies, assembly manifests should be installed as a separate file in the side-by-side assembly cache. This is usually the WinSxS folder in the Windows directory.
  • As manifests that accompany private assemblies, assembly manifests should installed in the directory structure of the application. This is usually a separate file in the same folder as the application's executable file.
  • As a resource in a DLL, the assembly is available for the private use of the DLL. An assembly manifest cannot be included as a resource in an EXE. An EXE file may include anapplication manifest as a resource.

File Name Syntax

The name of an assembly manifest is any valid file name followed by .manifest.

For example, an assembly manifest that refers to myassembly would use the following file name syntax. You can omit the <resource ID> field if the assembly manifest is being installed as a separate file or if the resource ID is 1.

myassembly.<resource ID>.manifest
Note  Because of the way side-by-side searches for private assemblies, the following naming restrictions apply when packaging a DLL as a private assembly. A recommended way of doing this is to put the assembly manifest in the DLL as a resource. In this case, the resource ID must equal 1 and the name of the private assembly may be the same as the name of the DLL. For example, if the name of the DLL is Microsoft.Windows.mysample.dll, the value of the name attribute used in the assemblyIdentity element of the manifest may also be Microsoft.Windows.mysample. An alternate way is to put the assembly manifest in a separate file. In this case, the name of the assembly and its manifest must be different than the name of the DLL. For example, Microsoft.Windows.mysampleAsm, Microsoft.Windows.mysampleAsm.manifest, and Microsoft.Windows.Mysample.dll. For more information about how side-by-side searches for private assemblies, see Assembly Searching Sequence.
 

Elements

Names of elements and attributes are case-sensitive. The values of elements and attributes are case-insensitive, except for the value of the type attribute.

assembly

A container element. Its first subelement must be an assemblyIdentity ornoInheritable element. The assembly manifest uniquely describes the side-by-side assembly identified by theassemblyIdentity. Required.

The assembly element must be in the namespace "urn:schemas-microsoft-com:asm.v1". Child elements of the assembly must also be in this namespace, by inheritance or by tagging.

The assembly element has the following attribute.

AttributeDescription
manifestVersionThe manifestVersion attribute must be set to 1.0.

 

noInheritable

Include this element in an assembly manifest to indicate that the assembly manages theactivation contexts and its objects. The noInheritable element must be a subelement of anassembly element. The assemblyIdentity element should come after anynoInheritable element. The noInheritable element is required in the assembly manifest if the assembly is used by anyapplication manifests that include the noInherit element. A noInheritable element in an application manifest has no effect. A noInheritable element has no child elements.

assemblyIdentity

Describes and uniquely identifies a side-by-side assembly.

As the first subelement of an assembly element, assemblyIdentity describes and uniquely identifies the side-by-side assembly that owns this assembly manifest. This is called the DEF-contextassemblyIdentity of the assembly manifest.

As the first subelement of a dependentAssembly element, assemblyIdentity describes and uniquely identifies a side-by-side assembly that is used by the DEF-contextassemblyIdentity. This is called a REF-context assemblyIdentity of the assembly manifest. The DEF-context assembly requires the REF-context assembly to work correctly. Note that every REF-contextassemblyIdentity must exactly match a corresponding DEF-context assemblyIdentity in the referenced assembly's own assembly manifest.

This element has no subelements. The assemblyIdentity element does have the following attributes.

AttributeDescription
typeSpecifies the assembly type. The value must be win32 and in lower case. Required.
nameUniquely names the assembly. Use the following format for the assembly name: Organization.Division.Name. For example, Microsoft.Windows.mysampleAsm. Required.

Note that in the case of a DLL packaged as a private assembly with a separate manifest file, the name of the assembly must be different than the name of the DLL and the manifest.

languageIdentifies the language of the assembly. Optional. If the assembly is language-specific, specify the DHTML language code.

In the DEF-context assemblyIdentity of an assembly manifest intended for worldwide use (language neutral) omit the language attribute.

In a REF-context assemblyIdentity of an assembly manifest intended for worldwide use (language neutral) set the value of language to "*".

processorArchitectureSpecifies the processor. The valid values are x86 for 32-bit Windows and ia64 for 64-bit Windows. Optional.
versionSpecifies the assembly version. Use the four-part version format: mmmmm.nnnnn.ooooo.ppppp. Each of the parts separated by periods can be 0-65535 inclusive. For more information, seeAssembly Versions. Required.
publicKeyTokenA 16-character hexadecimal string representing the last 8 bytes of the SHA-1 hash of the public key under which the assembly is signed. The public key used to sign the catalog must be 2048 bits or greater. Required for shared side-by-side assemblies.

 

dependency

A container element including at least one dependentAssembly. The first subelement must be adependentAssembly element. A dependency has no attributes. Optional.

dependentAssembly

The first subelement must be an assemblyIdentity element that describes and uniquely identifies a side-by-side assembly that is used by the side-by-side assembly that owns this assembly manifest. EverydependentAssembly must be inside exactly one dependency. Optional.

file

Contains files used by a side-by-side assembly. Contains comClass,typelib, windowClass, comInterfaceProxyStub subelements. Optional.

The file element has the following attributes.

AttributeDescription
nameName of the file, for example, Conctl32.dll.
hashalgAlgorithm used to create a hash of the file. This value should be SHA1.
hashA hash of the file referred to by name. A hexadecimal string of length depending on the hash algorithm.

 

comClass

A subelement of a file element. Optional.

The comClass element has the following attributes.

AttributeDescription
descriptionClass name.
clsidThe GUID that uniquely identifies the Class. Required. The value must be in the format of a valid GUID.
threadingModelThe threading model used by in-process COM classes. If this property is null, then no threading model is used. The component is created on the main thread of the client and calls from other threads are marshaled to this thread. Optional. Valid values are: "Apartment", "Free", "Both", and "Neutral".
tlbidGUID for the type library for this COM component. The value must be in the format of a GUID. Optional.
progidVersion-dependent programmatic identifier associated with the COM component. The format of a ProgID is <vendor>.<component>.<version>.
miscStatusDuplicates in the assembly manifest the information provided by the MiscStatus registry key. If values for themiscStatusIcon, miscStatusContent, miscStatusDocprint, ormiscStatusThumbnail attributes are not found, the corresponding default value listed inmiscStatus is used for the missing attributes. The value can be a comma-delimited list of the attribute values from the table below. You can use this attribute if the COM class is an OCX class that requires Miscstatus registry key values.
miscStatusIconDuplicates in the assembly manifest the information provided by DVASPECT_ICON. It can provide an icon of an object. The value can be a comma-delimited list of the attribute values from the table below. You can use this attribute if the COM class is an OCX class that requires Miscstatus registry key values.
miscStatusContentDuplicates in the assembly manifest the information provided by DVASPECT_CONTENT. It can provide a compound document displayable for a screen or printer. The value can be a comma-delimited list of the attribute values from the table below. You can use this attribute if the COM class is an OCX class that requires Miscstatus registry key values.
miscStatusDocprintDuplicates in the assembly manifest the information provided by DVASPECT_DOCPRINT. It can provide an object representation displayable on the screen as though printed to a printer. The value can be a comma-delimited list of the attribute values from the table below. You can use this attribute if the COM class is an OCX class that requires Miscstatus registry key values.
miscStatusThumbnailDuplicates in an assembly manifest the information provided by DVASPECT_THUMBNAIL. It can provide a thumbnail of an object displayable in a browsing tool. The value can be a comma-delimited list of the attribute values from the table below. You can use this attribute if the COM class is an OCX class that requires Miscstatus registry key values.

 

The comClass element can have <progid>...</progid> elements as children, which list the version dependent progids.

The following example shows a comClass element included in a file element.

<file name="sampleu.dll">
        <comClass description="Font Property Page"
    clsid="{0BE35200-8F91-11CE-9DE3-00AA004BB851}"
          threadingModel = "Both"
             tlbid = "{44EC0535-400F-11D0-9DCD-00A0C90391D3}"/>
        <comClass description="Color Property Page"
    clsid="{0BE35201-8F91-11CE-9DE3-00AA004BB851}" 
    progid="ABC.Registrar"/>
    </file>

If your COM class is an OCX class that requires the MiscStatus registry subkey to specify how to create and display an object, you can enable the object by duplicating this information in the assembly manifest. Specify the object's characteristics by using the miscStatus, miscStatusIcon, miscStatusContent,miscStatusDocprint, and miscStatusThumbnail attributes of thecomClass element. Set these attributes to a comma-separated list of attribute values from the following table. These attributes duplicate the information that would be provided by a DVASPECT enumeration. If a no value is found formiscStatusIcon, miscStatusContent, miscStatusDocprint, ormiscStatusThumbnail, the default values specified in miscStatus is used. Use attribute values from the following table. These correspond to the bit flags of aOLEMISC enumeration.

Attribute ValueOLEMISC Constant
recomposeonresizeOLEMISC_RECOMPOSEONRESIZE
onlyiconicOLEMISC_ONLYICONIC
insertnotreplaceOLEMISC_INSERTNOTREPLACE
staticOLEMISC_STATIC
cantlinkinsideOLEMISC_CANTLINKINSIDE
canlinkbyole1OLEMISC_CANLINKBYOLE1
islinkobjectOLEMISC_ISLINKOBJECT
insideoutOLEMISC_INSIDEOUT
activatewhenvisibleOLEMISC_ACTIVATEWHENVISIBLE
renderingisdeviceindependentOLEMISC_RENDERINGISDEVICEINDEPENDENT
invisibleatruntimeOLEMISC_INVISIBLEATRUNTIME
alwaysrunOLEMISC_ALWAYSRUN
actslikebuttonOLEMISC_ACTSLIKEBUTTON
actslikelabelOLEMISC_ACTSLIKELABEL
nouiactivateOLEMISC_NOUIACTIVATE
alignableOLEMISC_ALIGNABLE
simpleframeOLEMISC_SIMPLEFRAME
setclientsitefirstOLEMISC_SETCLIENTSITEFIRST
imemodeTOLEMISC_IMEMODE
ignoreativatewhenvisibleOLEMISC_IGNOREACTIVATEWHENVISIBLE
wantstomenumergeOLEMISC_WANTSTOMENUMERGE
supportsmultilevelundoOLEMISC_SUPPORTSMULTILEVELUNDO

 

typelib

A subelement of a file element. Optional.

The typelib element has the attributes shown in the following table.

AttributeDescription
tlbidThe unique ID of the type library. Required.
versionThe two-part version number of the type library. If only the minor version number increases, all the features of the previous type library are supported in a compatible way. If the major version number changes, code that compiled against the type library must be recompiled. The version number of the type library may differ from the version number of the application. Required.
helpdirThe directory where the Help file for the types in the type library is located. If the application supports type libraries for multiple languages, the libraries may refer to different file names in the Help file directory. If no value, then specify "". Required.
resourceidThe hexadecimal string representation of the locale identifier (LCID). It is one to four hexadecimal digits with no 0x prefix and no leading zeros. The LCID may have a neutral sublanguage identifier. For more information, seeLocale Identifiers. Optional.
flagsThe string representation of the type library flags for this type library. Specifically, it should be one of "RESTRICTED", "CONTROL", "HIDDEN" and "HASDISKIMAGE". These are the values of theLIBFLAGS enumeration, and are the same flags specified in theuLibFlags parameter of the ICreateTypeLib::SetLibFlags method. Optional.

 

The following example shows a typelib element included in a file element.

<file name="sampleu.dll">
       <typelib tlbid="{44EC0535-400F-11D0-9DCD-00A0C90391D3}"
       version="1.0" helpdir=""/>
</file>
comInterfaceExternalProxyStub

The comInterfaceExternalProxyStub is a subelement of an assembly element and is used for automation interfaces. For example, IDispatch and its derived interfaces. Optional.

The default proxy-stub implementation is adequate for most automation interfaces, such as interfaces derived fromIDispatch. The interface proxy stub, and all other external proxy-stub interface implementations, must be listed in thecomInterfaceExternalProxyStub. The comInterfaceExternalProxyStub element has the attributes shown in the following table.

AttributeDescription
iidThe IID of the interface for which the proxy is being declared. Required. The value should be in the form: "{iid}".
baseInterfaceThe IID of the interface from which the one described by the iid attribute is derived. This attribute is optional. The value should be in the form: "{iid}".
numMethodsThe number of methods implemented by the interface. This attribute is optional. The value should be in the form: "n".
nameName of the interface as it would appear in code. For example, "IViewObject". This should not be a descriptive string. This attribute is optional. The value should be in the form: "name".
tlbidThe type library that contains the description of the interface specified by theiid attribute. This attribute is optional. The value should be in the form: "{tlbid}" .
proxyStubClsid32Maps an IID to a CLSID in 32-bit proxy DLLs.

 

The following example shows a comInterfaceExternalProxyStub element.

<comInterfaceExternalProxyStub 
  name="IAxWinAmbientDispatch" 
    iid="{B6EA2051-048A-11D1-82B9-00C04FB9942E}" 
    numMethods="35" 
  baseInterface="{00000000-0000-0000-C000-000000000046}"/>
comInterfaceProxyStub

A subelement of a file element. Optional.

If a file in the assembly implements a proxy stub, the corresponding file tag must include acomInterfaceProxyStub subelement having attributes that are identical to acomInterfaceProxyStub element. Marshaling interfaces between processes and threads may not work as expected if you omit some of thecomInterfaceProxyStub dependencies for your component.

The comInterfaceProxyStub element has the following attributes.

AttributeDescription
iidThe .IID of the interface for which the proxy is being declared. Required. The value should be in the form: "{iid}".
nameName of the interface as it would appear in code. For example, "IViewObject". This should not be a descriptive string. This attribute is optional. The value should be in the form: "name".
tlbidThe type library that contains the description of the interface specified by theiid attribute. This attribute is optional. The value should be in the form: "{tlbid}".
baseInterfaceThe IID of the interface from which the one described by the iid attribute is derived. This attribute is optional. The value should be in the form: "{iid}".
numMethodsThe number of methods implemented by the interface. This attribute is optional. The value should be in the form: "n".
proxyStubClsid32Maps an IID to a CLSID in 32-bit proxy DLLs.
threadingModelThe threading model used by in-process COM classes. If this property is null, then no threading model is used. The component is created on the main thread of the client and calls from other threads are marshaled to this thread. Optional. Valid values are: "Apartment", "Free", "Both", and "Neutral".

 

windowclass

The name of a windows class that is to be versioned. The windowclass element has the following attribute.

AttributeDescription
versionedThis attribute controls whether or not the internal window class name used in registration contains the version of the assembly containing the window class. The value of this attribute can be "yes" or "no". The default is "yes". The value "no" should only be used if the same window class is defined by a side-by-side component and an equivalent non-side-by-side component and you wish to treat them as the same window class. Note that the usual rules about window class registration apply—only the first component that registers the window class will be able to register it since it is not versioned.

 

The following example shows a windowclass element included in afile element.

<file name="comctl32.dll">
        <windowClass versioned="no">ToolbarWindow32</windowClass>
</file>

Example

The following is an example of an assembly manifest.

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" 
manifestVersion="1.0">
    <assemblyIdentity type="win32" name="Microsoft.Tools.SampleAssembly" version="6.0.0.0" processorArchitecture="x86" publicKeyToken="0000000000000000"/>
    <file name="sampleu.dll" hash="3eab067f82504bf271ed38112a4ccdf46094eb5a" hashalg="SHA1">
        <comClass description="Font Property Page" clsid="{0BE35200-8F91-11CE-9DE3-00AA004BB851}"/>
        <comClass description="Color Property Page" clsid="{0BE35201-8F91-11CE-9DE3-00AA004BB851}"/>
        <comClass description="Picture Property Page" clsid="{0BE35202-8F91-11CE-9DE3-00AA004BB851}"/>
    </file>
    <file name="bar.dll" hash="ac72753e5bb20446d88a48c8f0aaae769a962338" hashalg="SHA1"/>
    <file name="foo.dll" hash="a7312a1f6cfb46433001e0540458de60adcd5ec5" hashalg="SHA1">
        <comClass description="Registrar Class" clsid="{44EC053A-400F-11D0-9DCD-00A0C90391D3}" progid="ATL.Registrar"/>
    <comInterfaceProxyStub iid="{B6EA2051-048A-11D1-82B9-00C04FB9942E}" name=" IAxWinAmbientDispatch " tlbid="{34EC053A-400F-11D0-9DCD-00A0C90391D3}"/>
        <typelib tlbid="{44EC0535-400F-11D0-9DCD-00A0C90391D3}" version="1.0" helpdir=""/>
    </file>
    <file name="sampledll.dll" hash="ba62960ceb15073d2598379307aad84f3a73dfcb" hashalg="SHA1"/>
<windowClass>ToolbarWindow32</windowClass>
        <windowClass>ComboBoxEx32</windowClass>
        <windowClass>sample_trackbar32</windowClass>
        <windowClass>sample_updown32</windowClass>
</assembly>

 

 

社区附加资源

添加
显示:
    

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
假设你指的是 Go Walk 的清单文件,这里提供一份可能的示例: ```xml <?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="*" name="GoWalk" type="win32" /> <dependency> <dependentAssembly> <assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="*" publicKeyToken="6595b64144ccf1df" language="*" /> </dependentAssembly> </dependency> <dependency> <dependentAssembly> <assemblyIdentity type="win32" name="Microsoft.VC90.CRT" version="9.0.21022.8" processorArchitecture="x86" publicKeyToken="1fc8b3b9a1e18e3b" /> </dependentAssembly> </dependency> <dependency> <dependentAssembly> <assemblyIdentity type="win32" name="Microsoft.VC90.MFC" version="9.0.21022.8" processorArchitecture="x86" publicKeyToken="1fc8b3b9a1e18e3b" /> </dependentAssembly> </dependency> <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1"> <application> <!-- Windows 10 --> <supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" /> </application> </compatibility> </assembly> ``` 该清单文件与上面的示例类似,主要包括: 1. assemblyIdentity:程序的标识信息,包括版本号、处理器架构、名称和类型等。 2. dependency:程序所依赖的其他程序或组件,这里指明了需要使用的公共控件库 Microsoft.Windows.Common-Controls,以及 Microsoft Visual C++ 2008 运行库。 3. compatibility:程序所支持的操作系统版本,这里指定了支持 Windows 10。 该清单文件的作用与上面相同,是为了告诉操作系统程序所需要的依赖项和配置信息,以确保程序能够正常运行。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值