So you're trying to open a file, or your app is trying to create one, and Windows throws MK_E_INVALIDEXTENSION (0X800401E6) in your face. Annoying, right? Let's fix it. The error usually appears when a COM object calls MkParseDisplayName or MkParseDisplayNameEx with a file extension that isn't registered as a valid moniker. That's a mouthful, but what's actually happening is Windows can't map that extension to a CLSID because the registry entry is missing, corrupt, or pointing to a broken handler.
The Quick Fix: Rebuild the File Association
Most of the time, the extension causing trouble is .msg, .eml, .doc, or something your email client or Office app touches. The fix is to re-register the extension with the correct ProgID. Here's how:
- Press
Win + R, typeregedit, hit Enter. Yes, you're going into the registry. Back it up first if you're nervous. - Navigate to
HKEY_CLASSES_ROOT\.msg(replace.msgwith your problem extension). - Look at the
(Default)value. It should point to a ProgID likeOutlook.File.msgor similar. If it's blank, that's your problem. - Double-click
(Default)and set it to the correct ProgID. For Outlook .msg files, that's usuallyOutlook.File.msg. For .eml, it'sOutlook.File.eml. - Now go to
HKEY_CLASSES_ROOT\Outlook.File.msg\shell\open\commandand make sure the command points to the right executable. If it doesn't exist, you'll need to create it or repair Office.
If you don't know the ProgID, you can find it by opening a working file of the same type on another machine. Or just run a repair on the associated app. For Office, that's Control Panel > Programs > Microsoft Office > Change > Quick Repair. It takes two minutes and fixes this error more often than not.
Why This Actually Works
The reason step 3 matters is that MkParseDisplayName reads the extension from the display name and looks it up in HKEY_CLASSES_ROOT. If the extension key exists but has no default value, or the value points to a ProgID that doesn't exist, the function returns MK_E_INVALIDEXTENSION. Rebuilding that chain — extension to ProgID to CLSID to executable — makes the moniker parse succeed. It's not magic; it's just COM following a breadcrumb trail that someone stepped on.
Less Common Variations
Sometimes the extension is fine, but the COM object that owns it is broken. This happens with third-party shell extensions, old OCR tools, or PDF handlers that got half-uninstalled.
- Broken shell extension: Run
ShellExViewfrom NirSoft, sort by company, and disable non-Microsoft extensions. If the error goes away, re-enable them one by one to find the culprit. - Corrupt user profile: Log in as a different user. If the error doesn't happen there, your profile's registry hive is damaged. The fix is to create a new profile and migrate your data.
- Missing Visual C++ redistributable: Some COM components need specific VC++ runtimes. Install the latest
Visual C++ Redistributable for Visual Studio 2015-2022from Microsoft. It's a 20MB download that resolves a shocking number of weird COM errors. - Antivirus interference: Some AV products inject hooks into COM registration. Temporarily disable real-time protection and test. If it works, add an exclusion for the affected file type.
Prevention
Don't let a registry cleaner anywhere near your file associations. Those tools love to "optimize" HKEY_CLASSES_ROOT and break exactly what you just fixed. Also, uninstall old Office versions properly instead of deleting folders. And if you're a developer, always register your COM components with regsvr32 and test MkParseDisplayName with a real extension before shipping. The error is almost always a registration issue, not a code bug.
One more thing: if you're seeing this in a script or automation tool, check that you're passing a full path with a valid extension. MkParseDisplayName doesn't like URLs or paths with no extension at all. That's a different error, but people confuse the two all the time.