[一個小問題]Mainfest配置文件的version問題小結

  問題起源本身安裝好產品的新build,而後用本身本地編譯出來的其中一個DLL去替換到產品中,原本覺得能夠正常執行,可是卻發現這個新DLL沒法被Load,沒法被使用。html

  從Event Viewer裏找到了問題描述:ios

  ----------------------------------------------------------------------------------------------------redis

  Activation context generation failed for "C:\Program Files\Trend Micro\Messaging Security Agent\instDeferredCustomAction.dll".Error in manifest or policy file "C:\Program Files\Trend Micro\Messaging Security Agent\Microsoft.VC80.MFC.MANIFEST" on line 4. Component identity found in manifest does not match the identity of the component requested.安全

  Reference is Microsoft.VC80.MFC,processorArchitecture="amd64",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="8.0.50727.4053".ide

  Definition is Microsoft.VC80.MFC,processorArchitecture="amd64",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="8.0.50727.762".visual-studio

  Please use sxstrace.exe for detailed diagnosis.ui

  ----------------------------------------------------------------------------------------------------spa

  解決方法:component

    只需到產品安裝目錄下找到Microsoft.VC80.MFC.MANIFEST文件,而後修改其version從762變爲4053便可htm

  問題緣由:

    咱們的產品由visual studio 2005開發,依賴於Microsoft Visual C++ 2005(用戶的電腦需安裝vcredist_x86.exe,vcredist_x64.exe),我在本地開發時VC的版本是4053(緣由是我安裝了Visual C++ 2005 SP1 KB971090的安全更新,VC生成的manifest中引用的ATL/MFC/CRT庫的版本從8.0.50727.762變成了8.0.50727.4053),而出build的機器其編譯時依賴的VC版本是762(http://www.microsoft.com/zh-cn/download/details.aspx?id=5638),因此致使運行時出現此問題。

  知識擴展:

  1. Event Viewer對此定性爲error,描述爲SideBySide錯誤,什麼是SideBySide?

    從Visual Studio 2005開始,微軟創造了SideBySide DLL,創造這種DLL的初衷是許多程序可能會使用不一樣version的DLL,若是同一個DLL被替換爲新version的DLL,可能會致使程序Crash(稱之爲DLL Hell),SideBySide DLL正爲解決這一問題,也就有了Mainfest文件(與可執行程序或DLL相關)來指明哪一個version的DLL能夠被執行。Mainfest是個XML的描述文件,對於每一個DLL有DLL的Manifest文件,對於每一個應用程序Application也有本身的Manifest。

  

  目前對於這個問題的理解至此,但願從此遇到問題都能及時查找緣由。不斷進步:)

 

  參考:

  1. Working with Visual Studios C++ manifest files

    http://stackoverflow.com/questions/588712/working-with-visual-studios-c-manifest-files

  2. manifest的做用

    http://www.cppblog.com/kyelin/archive/2010/10/09/129163.html

  3. 終結VC2005分發包版本問題

    http://www.cnblogs.com/mixiyou/archive/2010/02/09/1663620.html

 

 

  Best Regards

相關文章
相關標籤/搜索