VirtualBox "Document is empty" Error (E_FAIL 0x80004005)

Fixing a corrupted .vbox settings file that prevents a VM from starting, by restoring from backup or reattaching the existing disk.

Problem

Trying to start a VM in VirtualBox threw a 'Document is empty' error and the machine wouldn't open at all. The error details showed the .vbox file was empty at line 1, column 0, with result code E_FAIL (0x80004005) (the full error text is in the code block below).

Cause

An unexpected system shutdown (power outage, blue screen, etc.) or a disk error interrupted VirtualBox while it was writing the XML-based .vbox settings file, leaving it corrupted at 0 KB.

Solution

Solved with two methods. Method 1 (recommended): VirtualBox was fully closed, the corrupted 0 KB .vbox file in the VM's folder was deleted, and VirtualBox's auto-generated .vbox-prev backup file was renamed by removing the '-prev' suffix so it became the new .vbox file; the machine showed up fine after reopening VirtualBox. When the backup was also corrupted, Method 2 was used instead: the broken machine was removed from the VirtualBox list using 'Remove only' (without deleting files), a new machine was created with the same name and OS type, and the original .vdi file was reattached via 'Use an existing virtual hard disk file', bringing the machine back up without any data loss. As a precaution, taking a Snapshot after important operations and avoiding abrupt host shutdowns while a VM is running is recommended going forward.

Document is empty.
Location: 'C:\Users\<user>\VirtualBox VMs\<vm-name>\<vm-name>.vbox', line 1 (0), column 1.
Result Code: E_FAIL (0X80004005)
Component: MachineWrap
Interface: IMachine {300763af-5d6b-46e6-aa96-273eac15538a}

# Yontem 1 - yedekten geri yukleme
# 1) VirtualBox'i tamamen kapat
# 2) C:\Users\<Kullanici>\VirtualBox VMs\<Makine>\ klasorune git
# 3) 0 KB'lik hatali <Makine>.vbox dosyasini sil
# 4) <Makine>.vbox-prev dosyasini "-prev" eki olmadan yeniden adlandir (.vbox)
# 5) VirtualBox'i tekrar ac

# Yontem 2 - mevcut VDI'yi yeni makineye baglama
# 1) Hatali makineyi sag tikla > Remove > "Remove only" sec (dosyalari silme!)
# 2) New ile ayni isim/OS turunde yeni makine olustur
# 3) "Use an existing virtual hard disk file" secip orijinal .vdi dosyasini sec
# 4) Makineyi baslat

View solution source on GitHub