Mi paquete de Visual Studio requiere el uso de una variable EnvDTE.DTE, pero siempre vuelve a ser nulo. Después de leer muchos hacks, todos dicen usar el método OnShellPropertyChange() (IVsShellPropertyEvents), pero a veces simplemente nunca se dispara, como si mi extensión nunca terminara de cargarse.VSIX: obtener el objeto DTE
Estoy usando VS2010 y comprobando tanto VSSPROPID_Zombie como ShellInitialized - sin trabajo. ? :(
Cualquier idea Este es el código que estoy usando:
public int OnShellPropertyChange(int propid, object var) {
if (propid == -9053 || (int) __VSSPROPID.VSSPROPID_Zombie == propid) { // -9053 = ShellInit
try {
if ((bool) var == false) {
Dte = GetService(typeof (SDTE)) as DTE;
Flow.Dte = Dte;
var shellService = GetService(typeof (SVsShell)) as IVsShell;
if (shellService != null)
ErrorHandler.ThrowOnFailure(shellService.UnadviseShellPropertyChanges(_cookie));
_cookie = 0;
}
} catch {
}
}
return VSConstants.S_OK;
}
EDIT: Bajo Experimental Instancia, funciona perfectamente y tarda unos 5 segundos para inicializar Sin embargo, una vez desplegado como VSIX - ella. simplemente no se dispara.
VSSPROPID4 me dio algunos problemas de ambigüedad, por lo que fui con el número entero por el momento. Cambiaré la condición y veré si funciona ahora, ¡gracias! –