I am converting a VS Addin to a VS Package.
I have this code in my VSIX Package class(that derives from Microsoft.VisualStudio.Shell.Package)
protected override void Initialize() {
base.Initialize();
var dte = this.GetService<DTE>() as DTE2;
if(dte != null) {
var x = dte.MainWindow;
However calling dte.MainWindow
in this context throws a NullReferenceException
.
Something must not be initialized then. When am I supposed to call dte.MainWindow
then?
In the VS Addin it was working when dte.MainWindow
was called from public void OnStartupComplete(ref Array custom) {
in the Connect
Addin type.