SXS_EARLY_DEACTIVATION (0X00003704) Fix: Activation Context Order
This error means a program tried to deactivate an activation context before its matching activation finished. It's usually bad COM code or a broken side-by-side assembly.
Cause 1: Corrupted or Mismatched Side-by-Side Assembly Manifest
What's actually happening here is that Windows uses activation contexts to manage DLL versions and COM objects at runtime. Each time a program uses a side-by-side assembly (like a Visual C++ redistributable or a DirectX runtime), it pushes a new activation context onto a stack. When deactivating, it can only pop the most recent one. If the manifest file says one thing but the actual DLLs are different, the activation context ID gets crossed up — the code thinks it's deactivating context A, but context B is actually on top.
I've seen this most often with old games or business apps that bundle their own Visual C++ 2005/2008 runtimes and then update to a newer version without unregistering properly. The error triggers during CoUninitialize() or a COM interface teardown.
How to fix it
- Open Command Prompt as Administrator.
- Run
sfc /scannowto check for system file corruption. This won't fix third-party manifests but rules out OS-level problems. - If the app is 32-bit, check
C:\Windows\SysWOW64\config\systemprofile\AppData\Local\Microsoft\Windows\SideBySidefor stray manifests. Delete any that look orphaned — but back them up first. - Reinstall the app's required Visual C++ redistributables in correct order: 2005, 2008, 2010, 2012, 2013, 2015-2022. Use the official Microsoft ones, not third-party bundles.
- For apps from Steam or GOG, verify file integrity through the launcher — they often replace manifests during updates.
The reason step 3 works is that Windows caches manifest files in the SideBySide folder. A stale manifest from an abandoned update can cause the activation context stack to point at a context that no longer exists, so the deactivation order check fails.
Cause 2: COM Object Lifetime Mismatch in Threading Code
This is the more technical cause. The error often shows up in multi-threaded applications where one thread calls CoInitializeEx() to set up COM, starts using objects, and then another thread (or a callback) tries to tear down COM by calling CoUninitialize() on a different activation context. Windows tracks COM apartments per thread, and each apartment has its own activation context stack. If you deactivate a context that wasn't activated on that thread, you get ERROR_SXS_EARLY_DEACTIVATION.
A real-world trigger: a C# desktop app using System.Windows.Forms with a native COM shim that spawns worker threads. The worker threads don't copy the activation context from the main thread before calling CoInitializeEx on themselves.
How to fix it in code
- If you control the source, wrap every COM call in a
usingblock that callsCoInitializeExon the thread thenCoUninitializein a finally block — but only if you own the thread lifecycle. - Use
Activator.CreateInstancewithActivationContextif you must create objects across threads. The key is to activate on the same thread that will deactivate. - For third-party apps you can't change, try setting
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\SideBySide\PreferExternalManifestto1(DWORD). This forces Windows to look at the app's own manifest instead of the system cache.
Cause 3: Antivirus or Security Software Intercepting Activation Context Calls
Less common but real. Some antivirus products hook into the ActivateActCtx and DeactivateActCtx Win32 APIs to scan the context for malicious code. If the hook swallows the activation context's pointer and returns early, the kernel sees an out-of-order deactivation. Avast and McAfee have both shipped broken updates that caused this exact error for users running Visual Studio 2019 and 2022.
How to fix it
- Temporarily disable all real-time protection. If the error goes away, you've found the culprit.
- Whitelist the application's folder in your antivirus — specifically the
.exeand any.manifestfiles it loads. - If that doesn't help, uninstall the security software, reboot, and test. If the error vanishes, switch to a different AV (Windows Defender is honestly fine for most people).
- Check the Windows Application Event Log under Event Viewer for event ID 33 or 35 from source SideBySide. They often contain the exact context name that failed.
Quick-Reference Summary
| Cause | Symptom | Fix |
|---|---|---|
| Corrupted side-by-side manifest | App crashes during startup or teardown, event log shows assembly version mismatch | Reinstall VC++ redistributables, clear SideBySide cache, verify app files |
| COM threading mismatch | Error only in multi-threaded scenarios, often crash on CoUninitialize | Fix code to activate/deactivate on same thread, or add manifest override registry key |
| Antivirus hooking | Error appears after AV update, happens across multiple unrelated apps | Disable AV, whitelist app, or switch to Defender |
If you're still stuck after these steps, grab a ProcMon trace filtering for CreateFile on *.manifest files — you'll see exactly which context Windows is trying to deactivate and where the stack order breaks.
Was this solution helpful?