用VS2010打开一个C/C++项目,随便选个源代码文件,编辑,报错提示遇到异常,可能由于某Add-in导致等blah blah blah…,确定无视提示后继续编辑,写完一个函数的proto后IDE卡死,稍候直接大红叉异常,只能强制结束进程。
开始按照提示信息,怀疑是VM Ware的Virtual Debugger插件导致,于是花了一会时间把插件以正常添加/删除方式卸载掉,重启IDE,错误依旧,发现被M$的提示信息误导了!
用VS的命令行方式挂log参数启动,devenv /log,触发错误提示后查看ActivityLog.xml日志,xsl顺利的解析出了2条大红色的错误信息:
System.InvalidCastException: Unable to cast COM object of type ‘System.__ComObject’ to interface type ‘Microsoft.VisualStudio.TextManager.Interop.IVsTextReplaceEvents’. This operation failed because the QueryInterface call on the COM component for the interface with IID ‘{CF9928D9-65AE-4319-A446-94ED5C45ECDE}’ failed due to the following error: 不支持此接口 (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)). at System.StubHelpers.StubHelpers.GetCOMIPFromRCW(Object objSrc, IntPtr pCPCMD, Boolean& pfNeedsRelease) at Microsoft.VisualStudio.TextManager.Interop.IVsTextReplaceEvents.OnReplace(ChangeInput[] pCI) at Microsoft.VisualStudio.Editor.Implementation.VsTextBufferAdapter.OnTextBufferChangedHighPriority(Object sender, TextContentChangedEventArgs e) at Microsoft.VisualStudio.Text.Utilities.GuardedOperations.RaiseEvent[TArgs](Object sender, EventHandler`1 eventHandlers, TArgs args)
System.InvalidCastException: Unable to cast COM object of type ‘System.__ComObject’ to interface type ‘Microsoft.VisualStudio.Editor.Implementation.IVsTextStreamEvents_Private’. This operation failed because the QueryInterface call on the COM component for the interface with IID ‘{96FC7D44-BCDD-4F00-AE4D-07E26B2C0E52}’ failed due to the following error: 不支持此接口 (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)). at System.StubHelpers.StubHelpers.GetCOMIPFromRCW(Object objSrc, IntPtr pCPCMD, Boolean& pfNeedsRelease) at Microsoft.VisualStudio.Editor.Implementation.IVsTextStreamEvents_Private.OnChangeStreamText(Int32 iPos, Int32 iOldLen, Int32 iNewLen, Int32 fLast) at Microsoft.VisualStudio.Editor.Implementation.VsTextBufferAdapter.OnTextBufferChanged(Object sender, TextContentChangedEventArgs e) at Microsoft.VisualStudio.Text.Utilities.GuardedOperations.RaiseEvent[TArgs](Object sender, EventHandler`1 eventHandlers, TArgs args)
有了具体错误信息,发现是某个VS编辑COM控件的注册信息丢失导致,最后还算轻松的找到了解决方法: