共用方式為


/MANIFESTDEPENDENCY (Specify Manifest Dependencies)

 

The latest version of this topic can be found at -MANIFESTDEPENDENCY (Specify Manifest Dependencies).

MANIFESTDEPENDENCY:manifest_dependency

  
## Remarks  
 /MANIFESTDEPENDENCY lets you specify attributes that will be placed in the <dependency\> section of the manifest file.  
  
 See [/MANIFEST (Create Side-by-Side Assembly Manifest)](../Topic/-MANIFEST%20\(Create%20Side-by-Side%20Assembly%20Manifest\).md) for information on how to create a manifest file.  
  
 For more information on the <dependency\> section of the manifest file, see [Publisher Configuration Files](https://msdn.microsoft.com/library/aa375682).  
  
 /MANIFESTDEPENDENCY information can be passed to the linker in one of two ways:  
  
-  Directly on the command line (or in a response file) with /MANIFESTDEPENDENCY.  
  
-  Via the [comment](../Topic/comment%20\(C-C++\).md) pragma.  
  
 The following example shows a /MANIFESTDEPENDENCY comment passed via pragma,  
  

#pragma comment(linker, ""/manifestdependency:type='Win32' name='Test.Research.SampleAssembly' version='6.0.0.0' processorArchitecture='X86' publicKeyToken='0000000000000000' language='*'"")

  
 which results in the following entry in the manifest file:  
  
  
 The same /MANIFESTDEPENDENCY comments can be passed at the command line as follows:  
  

"/manifestdependency:type='Win32' name='Test.Research.SampleAssembly' version='6.0.0.0' processorArchitecture='X86' publicKeyToken='0000000000000000' language='*'"

  
 The linker will collect /MANIFESTDEPENDENCY comments, eliminate duplicate entries, and then add the resulting XML string to the manifest file.  If the linker finds conflicting entries, the manifest file will become corrupt and the application will fail to launch (an entry may be added to the event log, indicating the source of the failure).  
  
### To set this linker option in the Visual Studio development environment  
  
1.  Open the project's **Property Pages** dialog box. For details, see [How to: Open Project Property Pages](../Topic/How%20to:%20Open%20Project%20Property%20Pages.md).  
  
2.  Expand the **Configuration Properties** node.  
  
3.  Expand the **Linker** node.  
  
4.  Select the **Manifest File** property page.  
  
5.  Modify the **Additional Manifest Dependencies** property.  
  
### To set this linker option programmatically  
  
1.  See [AdditionalManifestDependencies](assetId:///P:Microsoft.VisualStudio.VCProjectEngine.VCLinkerTool.AdditionalManifestDependencies?qualifyHint=False&autoUpgrade=True).  
  
## See Also  
 [Setting Linker Options](../Topic/Setting%20Linker%20Options.md)   
 [Linker Options](../Topic/Linker%20Options.md)