You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note the tool window is derived from ToolWindowPane and it has a dependency on the UserControl as follows.
publicclassTrialToolWindow:ToolWindowPane{/// <summary>/// Initializes a new instance of the <see cref="TrialToolWindow"/> class./// </summary>publicTrialToolWindow(TrialToolWindowControltrialToolWindowControl):base(null){this.Caption="TrialToolWindow";// This is the user control hosted by the tool window; Note that, even if this class implements IDisposable,// we are not calling Dispose on this object. This is because ToolWindowPane calls Dispose on// the object returned by the Content property.this.Content=trialToolWindowControl;}}
But then, I wanted to explore the same with community tool kit extension packages.
So I created a Community tool kit project with Toolwindow as follows. This is different from the above.
Note here the tool window derives from Community.VisualStudio.Toolkit.BaseToolWindow and looks as follows.
If I create a regular VSIX project(not a community one)
add a tool window,
and then add Autofac Dependency Injection infrastructure. This works fine as expected.
I basically picked up the idea from this article by Akos Nagy.
My full working example is here.
Note the tool window is derived from ToolWindowPane and it has a dependency on the UserControl as follows.
But then, I wanted to explore the same with community tool kit extension packages.
So I created a Community tool kit project with Toolwindow as follows. This is different from the above.
Note here the tool window derives from Community.VisualStudio.Toolkit.BaseToolWindow and looks as follows.
In this case again, the tool window has a dependency on User Control, and if it is hard coded(no DI) then it works fine.
Now I want to add Autofac infrastructure, and here is where the problem begins. The tool window does not show up. My project for this case is here
As tried to dig deeper into the BaseToolWindow class, I found that the problem is here when an object is newed up as follows.
We know newing up stuff like that is a cardinal sin in DI, so I think is the problem.
But I am not sure the community development team did a mistake?
Or am I missing something here?
Is there some other/better way to do DI, that I am missing here?
The text was updated successfully, but these errors were encountered: