一分鐘明確 VS manifest 原理

來源:互聯網
上載者:User

標籤:os   io   檔案   art   ar   div   new   window   

什麼是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的重新導向。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.