什么是vs 程序的manifest文件
manifest 是VS程序用來標明所依賴的side-by-side組建,如ATL, CRT等的清單。
為什么要有manifest文件
一臺pc上,用一組建往往會有不止一個版本號(c:/windows/winsxs或系統文件夾下),程序在載入的時候,不知載入哪個,于是manifest文件來指明。
manifest在哪兒,怎樣創建。
假設用VS開發,能夠Set通過porperty->configuration properties->linker->manifest file->Generate manifest To Yes來自己主動創建manifest來指定系統的和CRT的assembly版本號。
除了這樣產生外部的manifest file,還有embedded manifest信息能夠被寫到所生成的二進制文件內
Set porperty->configuration properties->manifest tool->embed manifest? To Yes
對于xp及早前的windows版本號,external manifest會比embed manifest有更高的優先級,但對于windows server及后的版本號,相反。
為什么我的manifest明明指明
name="Microsoft.VC80.DebugCRT" version="8.0.50608.0",
可是用depends.exe工具卻發現引用的是8.00.50727.42呢?
由于在C:/WINDOWS/WinSxS/Policies下,有publisher configuration file也叫policy文件,如8.0.50727.42.policy文件對依賴做了重定向:
<dependentAssembly>
<assemblyIdentity type="win32" name="Microsoft.VC80.DebugCRT" processorArchitecture="ia64" publicKeyToken="1fc8b3b9a1e18e3b"/>
<bindingRedirect oldVersion="8.0.41204.256-8.0.50608.0" newVersion="8.0.50727.42"/>
</dependentAssembly>
指明"8.0.41204.256-8.0.50608.0"都被定向到8.0.50727.42。這是assembly提供商如MS對低級版本號bug的修正而提供的解決方法。除此之外,你也能夠用application config文件來對本程序做assembly的重定向。如在你bin local目錄下 yourbin.extention.config:
<configuration>
?????? <windows>
?????????? <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
??? ????? <dependentAssembly>
??? ??? <assemblyIdentity type="win32" name="Microsoft.VC80.ATL" processorArchitecture="x86" publicKeyToken="1fc8b3b9a1e18e3b"></assemblyIdentity>
??? ??? <bindingRedirect oldVersion="8.0.41204.256-8.0.50608.0" newVersion="8.0.50727.42"/>
??? ????? </dependentAssembly>
??? ????? <dependentAssembly>
??? ??? <assemblyIdentity type="win32" name="Microsoft.VC80.DebugCRT" processorArchitecture="x86" publicKeyToken="1fc8b3b9a1e18e3b"/></assemblyIdentity>
??? ??? <bindingRedirect oldVersion="8.0.41204.256-8.0.50608.0" newVersion="8.0.50727.42"/>
??? ????? </dependentAssembly>
??? ?? </assemblyBinding>
?????? </windows>
</configuration>
怎樣決定我程序manifest信息所指定的assembly版本號信息?
在assembly頭文件里,assembly的版本號信息被指明了。如crtassem.h中
#ifndef _CRT_ASSEMBLY_VERSION
#define _CRT_ASSEMBLY_VERSION "8.0.50608.0"
#endif
能夠改動8.0.50608.0為8.0.50727.42以產生你想要的manifest信息。
若我想將我的程序公布為獨立程序集(isolated application),不去依賴目標pc的系統assembly,該怎么辦?
帶上全部依賴的assembly和對應的manifest文件(c:/windows/winsxs),注意,manifest信息要直接能夠指定到所附帶的assembly DLLs,不須要依賴policy的重定向。