VS2010代碼編輯窗口第一次編輯操作導致報錯的問題

用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控件的註冊信息丟失導致,最後還算輕鬆的找到了解決方法:




用註冊表編輯器regedit按系統類型進入以下位置


32-Bit Windows: [HKEY_CLASSES_ROOT\CLSID\{73B7DC00-F498-4ABD-AB79-D07AFD52F395}\InProcServer32]


64-Bit Windows: [HKEY_CLASSES_ROOT\Wow6432Node\CLSID\{73B7DC00-F498-4ABD-AB79-D07AFD52F395}\InProcServer32]


補全此項的默認鍵值
32-Bit Windows: "C:\Program Files\Common Files\Microsoft Shared\MSEnv\TextMgrP.dll"
64-Bit Windows: "C:\Program Files (x86)\Common Files\Microsoft Shared\MSEnv\TextMgrP.dll"


再次啓動,錯誤消失。


參考鏈接:


http://stackoverflow.com/questions/4791519/visual-studio-crash-when-typing-in-editor






轉載地址:http://blog.k-res.net/archives/981.html
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章