Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Visual Studio.NET / Extensibility / November 2007

Tip: Looking for answers? Try searching our database.

EnvDTE80.Windows2.CreateToolWindow2 woes

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Alex Blekhman - 24 Nov 2007 17:51 GMT
Hello,

I have C# add-in for VS2005. From this add-in I create tool
window:

private void InitToolWindow()
{
   if (_MyAddInWnd == null)
   {
       EnvDTE80.Windows2 toolWins =
           (Windows2)_applicationObject.Windows;

       object objOut = null;

       _MyAddInWnd = toolWins.CreateToolWindow2(
           _addInInstance,
           Assembly.GetExecutingAssembly().Location,
           "MyAddInAddIn.MyAddInCtrl",
           "Caption string",
           "{GUID string goes here}",
           ref objOut
       );

      _MyAddInCtrl = (MyAddInCtrl)objOut;
   }
}

Both user control and add-in are in the same assembly, so
everything goes smoothly. Except that user control being
created twice!

When user invokes menu command for my add-in and tool window
becomes visible for the first time, then new user control is
created, so `_MyAddInCtrl' member of `Connect' class has
nothing to do with newly created control.

I tried to use `Window.Object' property instead of member
variable:

InitToolWindow();

MyAddInCtrl addInCtrl =
   (MyAddInCtrl)_MyAddInWnd.Object;
addInCtrl.SomeProp = 42;
...

The result is the same. Once `_MyAddInWnd' becomes visible
for the fist time, new user control is created.

How can I ensure that only one instance of user control is
created?

Thanks in advance
Alex
Alex Blekhman - 27 Nov 2007 09:35 GMT
> I have C# add-in for VS2005. From this add-in I create
> tool window:
> [...]
> Both user control and add-in are in the same assembly, so
> everything goes smoothly. Except that user control being
> created twice!

I discovered that actually the whole add-in is created
twice, not just user control. So, second creation of user
control is logical and expected. The real question now is
how to control the lifetime of an add-in. I'll start new
thread with appropriate subject.

Alex

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.