Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> ระบบ >> Windows Server

แอปพลิเคชันเริ่มต้นไม่ได้ เนื่องจาก Side-by-Side Configuration ผิดพลาด

หากเห็น Error "The application has failed to start because its side-by-side configuration is incorrect" ตอนพยายามเริ่ม App ใน Windows หมายถึงโปรแกรมไม่สามารถเริ่มได้เนื่องจาก Missing Dependencies Components ที่จำเป็นสำหรับรัน App เสียหายหรือไม่ได้ติดตั้ง บทความนี้แสดงวิธีตรวจสอบ Manifest File ของแอปพลิเคชัน และแก้ไข Dependencies โดยหา Library หรือ Package ที่ต้องติดตั้ง เพื่อให้ App เริ่มทำงานได้ถูกต้อง

ปัญหาเกิดบ่อยกับ Portable Apps หรือ Games เพราะใช้ Libraries ของ Microsoft Visual C++ Redistributable (vc_redist.x86.exe, vc_redist.x64.exe) ที่ไม่ได้ติดตั้งบนคอมพิวเตอร์หรือเสียหาย อย่างไรก็ตาม ก่อนจะติดตั้ง Visual C++ Redistributable ทุก Version โดยไม่คิด เราจะพยายามหาว่า App ต้องการ Library ไหนพอดีจาก Manifest File

แอปพลิเคชันเริ่มต้นไม่ได้ เนื่องจาก Side-by-Side Configuration ผิดพลาด

วิธีวิเคราะห์ App Manifest ใน Windows

ลองรัน Application makeappx.exe บนคอมพิวเตอร์ที่ไม่มี Windows SDK ติดตั้ง

Makeappx.exe ใช้สร้าง UWP App Packages ในรูปแบบ *.msix, *.appx, *.msixbundle, หรือ *.appxbundle

ชัดเจนว่า Tool ไม่เริ่มทำงาน และคืน Error:

Program 'makeappx.exe' failed to run: The application has failed to start because its side-by-side configuration is incorrect. Please see the application event log or use the command-line sxstrace.exe tool for more detail + CategoryInfo : ResourceUnavailable: (:) [], ApplicationFailedException + FullyQualifiedErrorId : NativeCommandFailed

แอปพลิเคชันเริ่มต้นไม่ได้ เนื่องจาก Side-by-Side Configuration ผิดพลาด

สังเกตข้อความ ResourceUnavailable ชี้ให้เห็นโดยตรงว่า App ขาดสิ่งที่ต้องการเพื่อรัน

รายการ Components และ Libraries ที่ App ต้องการระบุอยู่ใน App Manifest Manifest อาจเก็บเป็น XML File แยก หรือ Embed ตรงใน Executable (.exe) File

ดู Manifest ของ EXE File ได้ด้วย Tool ฟรี Manifest View หรือ Resource Hacker

แสดงวิธีใช้ Resource Hacker ดูและแก้ไข App Manifest ในบทความ How to suppress UAC elevation prompt?

เห็นว่า Section Dependency ใน App Manifest มี Reference ไปที่ Microsoft.Windows.Build.Appx.AppxPackaging.dll Application ไม่สามารถทำงานได้โดยไม่มี Library File นี้

แอปพลิเคชันเริ่มต้นไม่ได้ เนื่องจาก Side-by-Side Configuration ผิดพลาด

ยังสามารถ Trace Application Startup ด้วย SxSTrace.exe

เปิด Command Prompt ใหม่ เริ่มเก็บข้อมูลด้วยคำสั่ง:

sxstrace.exe Trace -logfile:c:\tmp\makeapp_sxtracesxs.etl

Tracing started. Trace will be saved to file c:\tmp\makeapp_sxtracesxs.etl. Press Enter to stop tracing...

จากนั้นรัน Problem App เมื่อ Error "The application has failed to start because its side-by-side configuration is incorrect" ปรากฏ หยุด Tracing โดยกด ENTER ในหน้าต่าง sxstrace

แอปพลิเคชันเริ่มต้นไม่ได้ เนื่องจาก Side-by-Side Configuration ผิดพลาด

แปลง ETL Log File ให้เป็น TXT Format ที่สะดวกกว่า:

sxstrace.exe Parse -logfile:c:\tmp\makeapp_sxtracesxs.etl -outfile:c:\tmp\makeapp_sxtracesxs.txt

เปิด TXT File ที่ได้ใน Notepad (หรือ Text Editor อื่น) หาบรรทัดที่มี Error สามารถ Grep Error ใน Text File ด้วย PowerShell

Get-Content c:\tmp\makeapp_sxtracesxs.txt | Where-Object { $_.Contains("ERROR") }

เห็นว่า Error ชี้ไปที่ DLL File เดียวกับที่เห็นใน App Manifest:

INFO: End assembly probing. ERROR: Cannot resolve reference Microsoft.Windows.Build.Appx.AppxPackaging.dll,version="0.0.0.0". ERROR: Activation Context generation failed.

แอปพลิเคชันเริ่มต้นไม่ได้ เนื่องจาก Side-by-Side Configuration ผิดพลาด

เพิ่มเติม สามารถวิเคราะห์ SideBySide Dependency Errors ด้วย Event Logs หาก Error เกิดขึ้น Event ต่อไปนี้จะถูกเขียนใน Application Log:

EventID: 33 Source: SideBySide

Error Description อ้างถึง Library File หรือ Component ที่จำเป็นสำหรับรัน App

Activation context generation failed for "C:\ps\test\makeappx.exe". Dependent Assembly Microsoft.Windows.Build.Appx.AppxPackaging.dll,version="0.0.0.0" could not be found. Please use sxstrace.exe for detailed diagnosis.

แอปพลิเคชันเริ่มต้นไม่ได้ เนื่องจาก Side-by-Side Configuration ผิดพลาด

จากนั้นค้นหาข้อมูล DLL นี้ใน Google ในตัวอย่าง Library File เป็นส่วนหนึ่งของ MSIX Toolkit จาก Windows SDK (Redist.x86) ดาวน์โหลดและติดตั้ง Components ที่พบ เพื่อให้ App เริ่มทำงานได้ถูกต้อง

Troubleshooting Microsoft Visual C++ Redistributable

ในกรณีส่วนใหญ่ Error "Incorrect side-by-side configuration" เกี่ยวข้องกับ Missing หรือ Corrupted Version ของ Microsoft Visual C++ Redistributable Library

แอปพลิเคชันเริ่มต้นไม่ได้ เนื่องจาก Side-by-Side Configuration ผิดพลาด

ในกรณีนี้ Error ต่อไปนี้จะปรากฏทั้งใน sxstrace log และใน app manifest:

Error: Cannot resolve reference ERROR: Cannot resolve reference Microsoft.VC90.MFC, processorArchitecture="amd64", publicKeyToken="1fc8b3b9a1e18e3b", type="win32",version="9.0.21022.8".

ได้ข้อมูลว่า App ต้องการ x64-bit Microsoft.VC90.MFC 9.0.21022 ค้นหาใน Google เร็ว พบว่าเป็น Microsoft Visual C++ 2008 Redistributable ดาวน์โหลดและติดตั้ง MVC Version นี้จากเว็บไซต์ Microsoft

วิธีเดียวกันได้ Visual C++ Versions อื่นๆ จากค่าใน Field Version:

  • Microsoft Visual C++ Redistributable for Visual Studio 2015, 2017, and 2019: 14.0.x หรือใหม่กว่า
  • Microsoft Visual C++ 2013 Redistributable: 12.0.x
  • Microsoft Visual C++ 2012 Redistributable: 11.0.x
  • Microsoft Visual C++ 2010 Redistributable: 10.0.x
  • Microsoft Visual C++ 2008 Redistributable: 9.0.x

ซ่อม System Files ใน Windows

หากเข้าใจว่า App Startup Error เกี่ยวข้องกับ Windows System Files ให้ตรวจสอบและซ่อม Windows System Image Files และ Components ด้วย SFC และ DISM:

sfc /scannow
DISM.exe /Online /Cleanup-image /Scanhealth
DISM.exe /Online /Cleanup-image /Restorehealth