close

最近遇到某個MFC的執行檔出現錯誤訊息,無法開啟。

去"應用程式事件檢視器"看到錯誤訊息如下

"Microsoft.VC80.MFC,processorArchitecture="x86",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="8.0.50727.762"。"

安裝了一堆版本的C++可轉散發程式。

最後裝了這個

Note: In order to resolve the Side-by-Side example error described in this article it is preferable to install the C++ run-time package Microsoft Visual C++ 2005 Service Pack 1 Redistributable Package MFC Security Update.

才可以正常執行。特此紀錄一下。

下圖為目前所有安裝的VC redistribute套件


--

故事是這樣的: 吉米兄有一天寫了一支程式,他的開發環境是使用 VC 2005 C++ 來撰寫,功能很簡單,
讀取設定檔案,然後送信給設定檔中指定的 Email address和夾檔,程式Compile for debug mode 在開發機器上面測試運作良好
將檔案複製到他老舊的Win XP 機器上面也OK 可以動,但是在 deploy 程式到乾淨的機器上面,執行的時候出現下面的訊息。
附上中英文版 作業系統為 Windows Server 2008
ChtWin2008.jpg
EngWin2008.jpg
This application has failed to start because its side-by-side configuration is incorrect.
Please see the application event log for more detail.
如果使用 Windows 7 來執行的話出現的錯誤訊息會請你使用 sxstrace.exe 的工具來找出錯誤。(sxstrace.exe 的使用方法)

 


 

這時候請到事件檢視器裡面看,裡面會有更多的情報。
EventLog023.jpg 
番了一下Google 大神發現只要將下面的檔案複製到執行路徑中就可以解決問題
Microsoft.VC80.DebugMFC.manifest
Microsoft.VC80.DebugCRT.manifest
Search 了一下不能執行的機器,裡面確實沒有上面的檔案,這兩個檔案都可以使用 notepad 開起來,裡面記錄了 Dll 的版本和 has key
還有 CPU 是 32還是64的。
一開始以為隨便找個一樣的檔案複製進去到要 deploy 的機器上面就沒事了,但是如果:

 

  1. .程式使用 win32 編譯的話,你的 manifest 裡面卻是設定為 AMD64 (64版本) 程式一樣不會動
  2. .mainfest 第四行有記錄版號,像我目前的範例版號就是 version="8.0.50727.4053" 可是編譯的機器是使用 version="8.0.50727.762",複製不一樣版號的檔案也不給動

 

這檔案通常放在開發機器下面的路徑中:
32Bit OS:"C:\Program Files\Microsoft Visual Studio 8\VC\redist\Debug_NonRedist\x86
64Bit OS:"C:\Program Files (x86)\Microsoft Visual Studio 8\VC\redist\Debug_NonRedist\x86

 

  1. .Microsoft.VC80.DebugCRT (裡面會有相對應的 manifest 檔案和一堆Dll 我一古腦全部都複製到目標機器上面)
  2. .Microsoft.VC80.DebugMFC (裡面會有相對應的 manifest 檔案和一堆Dll 我一古腦全部都複製到目標機器上面)

 

CpyAllFile023.jpg
等待複製完畢~~wa la 程式就可以執行的說 ^^。
這次解決問題都要歸功於 Win7 上面的 Event log(事件檢視器詳細的描述,下面就貼上 trouble shutting 中的 log)

 

Activation context generation failed for "C:\MailMessage.exe".
Error in manifest or policy file "C:\Microsoft.VC80.DebugCRT.MANIFEST" on line 4. 
Component identity found in manifest does not match the identity of the component requested. 
Reference is Microsoft.VC80.DebugCRT,processorArchitecture="x86",
publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="8.0.50727.762". 
Definition is Microsoft.VC80.DebugCRT,processorArchitecture="x86",publicKeyToken="1fc8b3b9a1e18e3b",
type="win32",version="8.0.50727.4053". 
Please use sxstrace.exe for detailed diagnosis.

 

事過境遷~~~
有一次同事 Jessic 他老兄的 Office 2007 完全不能work, 他的作業系統為 Vista 面出現的錯誤訊息很類似,
也是出現並列組態錯誤,但是這次出現的錯誤我沒有瞬間和 Side by side 連在一起~~
但是也發現第二種解決辦法,這次的問題是因為他老兄 VC redistribute 2005 沒有安裝好
重新移除也移除不乾淨,最後搬出 MS 提供的工具 msicuu2.exe MS Installer cleaner 用它將 VC redistribute 2005 
移除然後重新安裝VC redistribute 2005 問題就迎刃而解~~,且我覺得這個 solution 才是王道,使用 Hack 的方式喂 DLL... 
有點腳痛醫腳頭痛醫頭的感覺。

--

轉自 https://www.veritas.com/support/en_US/article.000125536

http://wiki.alarmchang.com/index.php?title=%E7%A8%8B%E5%BC%8F%E7%84%A1%E6%B3%95%E5%9F%B7%E8%A1%8C%EF%BC%8C%E5%87%BA%E7%8F%BE_SideBySide_%E7%9A%84%E9%8C%AF%E8%AA%A4%E8%A8%8A%E6%81%AF(This_application_has_failed_to_start_because_its_side-by-side_configuration_is_incorrect...)

--

 

Description

A Windows "Side-by-Side" error occurs when a Windows application is unable to locate a dll file that the application depends on. 

Side-by-Side assemblies and manifests
"Side-by-Side", also known as "WinSxS", "SxS" or "Fusion", is an extension to the Windows application model that allows software components to express dependency information. A Side-by-Side "assembly" contains a collection of resources - usually a group of dlls - that are always provided to applications together. These files are described in the assembly "manifest". The Microsoft Visual C++ run-time libraries are an example of an assembly that contains multiple dll files. Both Visual Studio 2005 and 2008 employ Side-by-Side when building a program, including an embedded binary manifest that records the C++ run-time version information. When that program runs, the Side-by-Side manager determines whether the application has a version dependence described in a manifest. (If there is no relevant manifest, the system loads the default version of the assembly).

 

Real-life example of a Side-by-Side error during OCR
An issue reported by some Clearwell users is that of all OCR failing with the "general" OCR error being reported in the OCR log file D:\CW\VXXX\logs\OCRConverter_output.log:

2016-09-09 15:27:36,381 INFO  [OCRConverter] (10856:OCRConverter) Starting OCR conversion process
2016-09-09 15:27:36,394 ERROR [OCRConverter] (10856:OCRConverter) Conversion of D:\CW\V811R1\scratch\temp\esadb\dataStore_case_awda6d5rmj_20692977\cache02\AttHT
MLCache\daa\367\69a772c0858385d1d5ba46df9b\d00\1\1.JPG failed, error was: Err : Error code = 8004C40D API_ERROR_ERR: General error in the Engine.

One big difficultly when troubleshooting OCR issues is that the OCR software always reports this same "general" error message.  However, if a Side-by-Side error has caused the OCR to fail, an additional error will be recorded in the Windows Application Event log (Figure 1).

Figure 1.
Event Log screenshot

Here is the error shown in Figure 1:

Activation context generation failed for "D:\CW\V811R1\exe\ocr\WC_OPSteps.dlm". Dependent Assembly
Microsoft.VC80.MFC,processorArchitecture="x86",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="8.0.50727.762" could not be found.
Please use sxstrace.exe for detailed diagnosis.


This error indicates that the OCR application was built with a dependency on version 8.0.50727.762 of the assembly Microsoft.VC80.MFC. This assembly version number corresponds to the C++ run-time package Microsoft Visual C++ 2005 SP1 Redistributable Package (x86). The error shown above can therefore be resolved by installing the missing C++ run-time package. 

 

The sxstrace.exe utility
The sxstrace.exe utility (mentioned in the error in the Windows Event Log) can be used to determine the C++ run-time version that a program depends on. The following steps show how to capture a trace for an OCR that is run from the command-line (an excellent way to verify if OCR is working):

  1. Launch a command window and change to the directory D:\CW\VXXX\exe\ocr
    Note: It has been found that the sxstrace.exe utility must be run from inside the D:\CW\VXXX\exe\ocr directory in order to generate a full capture.
  2. Start the capture with a specified output file name:
    D:\CW\VXXX\exe\ocr>sxstrace.exe trace -logfile:D:\mytrace.etl
  3. Start a second command window and run the OCR command-line, specifying the input file and an output file name:
    D:\CW\VXXX\exe\ocr>OCRConverter.exe -i d:\ocr_test\SAMPLE1.tif -o d:\ocr_test\out.txt
    Note: When running an OCR test on the command-line like this, the command must be run from inside the D:\CW\VXXX\exe\ocr directory.
    Note: This example uses the same file SAMPLE1.tif that can be found in the Clearwell product directory D:\CW\VXXX\exe\ocr
  4. In the command window that is running the capture, stop the capture by simply pressing <Enter>.
  5. Convert the capture file to text format:
    D:\>sxstrace.exe parse -logfile:d:\mytrace.etl -outfile:d:\mytrace.txt

The trace confirms that the OCR file WM_OPSteps.dlm has a dependency on Microsoft.VC80.MFC version 8.0.50727.762:
=================
Begin Activation Context Generation.
Input Parameter:
    Flags = 0
    ProcessorArchitecture = Wow32
    CultureFallBacks = en-US;en
    ManifestPath = D:\CW\V82\exe\ocr\WM_OPSteps.dlm
    AssemblyDirectory = D:\CW\V82\exe\ocr\
    Application Config File = 
-----------------
INFO: Parsing Manifest File D:\CW\V82\exe\ocr\WM_OPSteps.dlm.
    INFO: Manifest Definition Identity is (null).
    INFO: Reference: Microsoft.VC80.CRT,processorArchitecture="x86",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="8.0.50727.762"
    INFO: Reference:Microsoft.VC80.MFC,processorArchitecture="x86",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="8.0.50727.762"

Note: This trace indicates that this particular component of the OCR software was built with a dependency on the C++ run-time package Microsoft Visual C++ 2005 SP1 Redistributable Package (x86), However, as we will see shortly, the Clearwell appliance does not actually need to have this exact same run-time package installed in order for the OCR to work.

 

Re-directed assembly versions
If we examine more of the sxstrace trace that we captured earlier, which was taken from a successful OCR, we see that the OCR application actually used version 8.0.50727.6195 of Microsoft.VC80.MFC, and not version 8.0.50727.762:

    INFO: Resolving reference for ProcessorArchitecture x86.
        INFO: Resolving reference for culture Neutral.
            INFO: Applying Binding Policy.
                INFO: Find publisher policy at C:\Windows\WinSxS\manifests\x86_policy.8.0.microsoft.vc80.mfc_1fc8b3b9a1e18e3b_8.0.50727.6195_none_49f31fd71413cdc6.manifest
                INFO: Publisher Policy redirected assembly version.
                INFO: Post policy assembly identity is Microsoft.VC80.MFC,processorArchitecture="x86",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="8.0.50727.6195".

The version number 8.0.50727.6195 corresponds to the C++ run-time package Microsoft Visual C++ 2005 Service Pack 1 Redistributable Package MFC Security Update. This is newer than Microsoft Visual C++ 2005 SP1 Redistributable Package (x86)

So why did our OCR work when version 8.0.50727.762 was not installed? The OCR worked because the C++ run-time version that was installed (8.0.50727.6195) includes a policy file that re-directs users of 8.0.50727.762 to 8.0.50727.6195. With version 8.0.50727.6195 installed, the policy file can be found here:

C:\Windows\WinSxS\Manifests\x86_policy.8.0.microsoft.vc80.mfc_1fc8b3b9a1e18e3b_8.0.50727.6195_none_49f31fd71413cdc6.manifest

This policy file includes some "assembly re-directions":
 <bindingRedirect oldVersion="8.0.41204.256-8.0.50608.0" newVersion="8.0.50727.6195"/>
 <bindingRedirect oldVersion="8.0.50727.42-8.0.50727.6195" newVersion="8.0.50727.6195"/>

This is why the OCR works successfully even when 8.0.50727.762 is not installed.

Note: In order to resolve the Side-by-Side example error described in this article it is preferable to install the C++ run-time package Microsoft Visual C++ 2005 Service Pack 1 Redistributable Package MFC Security Update.

 

The C:\Windows\WinSxS directory
The directory C:\Windows\WinSxS is the Side-by-Side store (also known as the "Windows component store"). It is conceptually the native equivalent of the .NET "Global Assembly Cache" (GAC). This directory contains the dll files and manifests associated with each Side-by-Side assembly. The size of this directory can grow to several GB in size as more applications are installed. As one might imagine however, uninstalling an application does not usually remove files from this directory, as the files could be needed by other applications. Note: Never modify the files in this directory.

Because the directory contains many files, a good way to search for relevant files is to specify the assembly name and the leading part of the assembly version number, for example:

C:\Windows\WinSxS>dir /s /b *Microsoft.VC80.MFC*50727*
C:\Windows\WinSxS\x86_microsoft.vc80.mfc_1fc8b3b9a1e18e3b_8.0.50727.6195_none_cbf5e994470a1a8f
C:\Windows\WinSxS\Manifests\x86_microsoft.vc80.mfc_1fc8b3b9a1e18e3b_8.0.50727.6195_none_cbf5e994470a1a8f.cat
C:\Windows\WinSxS\Manifests\x86_microsoft.vc80.mfc_1fc8b3b9a1e18e3b_8.0.50727.6195_none_cbf5e994470a1a8f.manifest
C:\Windows\WinSxS\Manifests\x86_policy.8.0.microsoft.vc80.mfc_1fc8b3b9a1e18e3b_8.0.50727.6195_none_49f31fd71413cdc6.cat
C:\Windows\WinSxS\Manifests\x86_policy.8.0.microsoft.vc80.mfc_1fc8b3b9a1e18e3b_8.0.50727.6195_none_49f31fd71413cdc6.manifest

If we list the files in directory C:\Windows\WinSxS\x86_microsoft.vc80.mfc_1fc8b3b9a1e18e3b_8.0.50727.6195_none_cbf5e994470a1a8f  we see all of the dll files in the assembly:

C:\>dir /b C:\Windows\WinSxS\x86_microsoft.vc80.mfc_1fc8b3b9a1e18e3b_8.0.50727.6195_none_cbf5e994470a1a8f
mfc80.dll
mfc80u.dll
mfcm80.dll
mfcm80u.dll

Note: Never modify the files in the C:\Windows\WinSxS directory.

 

Terms of use for this information are found in Legal Notices.

 

--

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 dizzy03 的頭像
    dizzy03

    碎碎念

    dizzy03 發表在 痞客邦 留言(0) 人氣()