Unable to cast COM object … to IVsGlobalUndoCapableUndoManager

Hi all, sorry for the absense – we're all really busy fixing Visual Studio 2010 performance, memory consumption, improving stability and fixing last minute bugs.

Good news: if you're seeing this:

Unable to cast COM object of type 'System.__ComObject' to interface type 'Microsoft.VisualStudio.Editor.Implementation.IVsGlobalUndoCapableUndoManager'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{305E8709-55B7-4732-B872-1C073AB58047}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).

then we know what's going on.

Workaround

Try running devenv.exe /nosplash to bypass the splash screen, and things should work fine.

WOOT??! How is the splash screen related??! :)

For the curious ones, here's what's happening:

…In my case I was investigating a fairly popular (5-6 new hits a day) Watson bucket. Ultimately I’ve found out, using some DistSvcs extension for WinDbg, that every dump has the splash screen thread as its main STA, followed by a crash. The symptoms are almost exactly the same as yours – IlocalRegistry::CreateInstance used on the WinMain thread, and returns a proxy for the newly created object. It seems to be a race condition between main thread and splash screen thread as to which one calls CoInitializeEx first (including implicit calls via various Win32 APIs), since we spin off the splash thread before we explicitly call OleInitialize (which calls CoInitialize) on the main thread.

After a LOT of investigations, the solution was finally found by Pavel Minaev and Michael Lehenbauer, developers on the Visual Studio platform team. Huge thanks goes to them and to Viacheslav Ivanov, who helped a lot by reporting the issue and providing valuable call stacks, minidumps and trying out various things for us!