Carlos J. Quintero semble en savoir beaucoup sur l'ETTD. Dans un article mis à jour en Mars de cette année et publié sur le Web (http://www.mztools.com/articles/2007/mz2007027.aspx), il dit que la méthode Open sur un EnvDTE. ProjectItem renvoie un EnvDTE.Window, dont la propriété Document peut être transtypée en un EnvDTE.TextDocument.DTE: tentative de conversion de Window.Document de ProjectItem en un objet TextDocument
Mais quand j'essaye ceci, j'obtiens une exception (HRESULT: 0x80004002 [E_NOINTERFACE]). Il semble que le __ComObject par open ne sait pas TextDocument:
Un (extrait et légèrement modifié) extrait de mon code VB .Net (VS2008 fonctionnant sous Windows 7 Pro 64 dans WOW):
...handler for BuildEvents.OnBuildBegin recursively traverses all items in all projects; filters names to find those containing ".Designer.vb" (apparently works fine to here). For each found, want to replace certain text; to do so, need TextDocument object:
'the below returns __ComObject instead of EnvDTE.Window
Dim ItemWindow as EnvDTE.Window = ProjectItem.Open(EnvDTE.Constants.vsext_vk_Code)
'the below throws exception
Dim ItemTextDocument as EnvDTE.TextDocument = CType(ItemWindow.Document, EnvDTE.TextDocument)
erreur complète:
Unable to cast COM object of type 'System.__ComObject' to interface type 'EnvDTE.TextDocument'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{CB218890-1382-472B-9118-782700C88115}' failed due to the following error: Interface wordt niet ondersteund (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).
Qu'est-ce qui ne va pas? Toute aide appréciée.
Merci pour votre aide – albondiga