VSIX CommandPackage中的DTE2.Documents异常

时间:2016-07-25 11:28:52

标签: visual-studio-2015 vsix

我试着这样做:

  Private _applicationObject As EnvDTE80.DTE2 = DirectCast(Me.ServiceProvider.GetService(GetType(SDTE)), DTE2)
  Dim docs As EnvDTE.Documents = _applicationObject.Documents
  Dim doc As EnvDTE.Document
  For Each doc In docs
  'foobar()
  Next

但是在第4行" docs"这是一个未知的COM异常。调用类的标题/扩展名:

<PackageRegistration(UseManagedResourcesOnly:=True)>
<InstalledProductRegistration("#3110", "#3112", "1.0", IconResourceID:=3400)>
<ProvideMenuResource("Menus.ctmenu", 1)>
<Guid(Command1Package.PackageGuidString)>
<ProvideAutoLoad(UIContextGuids80.SolutionExists)>
Public NotInheritable Class Command1Package
   Inherits Package

在Command Class中,我扩展了文档选项卡上的contextmenu。这有什么问题?好吧,我找到了解决方案,但想要了解这里的问题。 而不是文档我必须使用Windows并过滤kind =&#34; Document&#34;。

任何想法?

例外:

System.Runtime.InteropServices.COMException ist aufgetreten.
  ErrorCode=-2147467259
  HResult=-2147467259
  Message=Unbekannter Fehler (Ausnahme von HRESULT: 0x80004005 (E_FAIL))
  Source=""
  StackTrace:
       bei System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
       bei Microsoft.VisualStudio.Shell.Design.Serialization.DesignerDocDataService.Microsoft.VisualStudio.Shell.Interop.IVsRunningDocTableEvents.OnBeforeLastDocumentUnlock(UInt32 docCookie, UInt32 lockType, UInt32 readLocksRemaining, UInt32 editLocksRemaining)
       bei EnvDTE.Documents.GetEnumerator()
       bei TabContextMenuExt.Command1.CloseAllWorkingDocuments() in C:\_demos\jur\TabContextMenuExt\Command1.vb:Zeile 84.
  InnerException: 

0 个答案:

没有答案