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 / September 2006

Tip: Looking for answers? Try searching our database.

Determine when Visual Studio finished initial loading

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Notre Poubelle - 19 Sep 2006 05:38 GMT
Hello,

I am starting a new instance of Visual Studio from my own executable.  I
have my own editor in Visual Studio and the file type is associated with
Windows.  I would like to have Visual Studio open a file with my registered
extension, which would start my editor.  This seems to work for the most
part, except I sometimes get an error message, which I believe is related to
Visual Studio not being fully ready.  (If an instance of Visual Studio has
already started, then the scenario works without any errors).  I believe I
need to delay until some point where Visual Studio is ready to accept
commands.

Is there a way to determine when Visual Studio is ready for user action or
external automation?  Do I need to wait until all packages which are set to
load at start up with Visual Studio have finished loading?  Is there an
automation model, DDE commands, or some standard windows message (or anything
else) I could use to determine when Visual Studio has finished its initial
loading? I am using Visual Studio 2005, if that makes a difference.

Thanks,
Notre
Gary Chang[MSFT] - 19 Sep 2006 09:28 GMT
Hi Notre,

This is a quick note to let you know that I am performing research on this
issue and will get back to you as soon as possible. I appreciate your
patience.

Thanks for your understanding.

Best regards,

Gary Chang
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Dustin Campbell - 19 Sep 2006 14:13 GMT
Hi Nortre,

Have you tried connecting to the DTE2.Events.DTEEvents.OnStartUpComplete
event?

Best Regards,
Dustin Campbell
Developer Express Inc
Notre Poubelle - 19 Sep 2006 17:16 GMT
Hi Dustin,

No I haven't tried that.  It sounds very promising!  Do you know how I would
get a hold of the DTE2 object from an external process (the one that launched
VS)?

Thanks,
Notre
Dustin Campbell - 19 Sep 2006 17:34 GMT
> No I haven't tried that.  It sounds very promising!  Do you know how I
> would get a hold of the DTE2 object from an external process (the one
> that launched VS)?

Here's C# sample code that retrieves the DTE2 object from an already running
Visual Studio 2005 instance:

EnvDTE80.DTE2 dte = Marshal.GetActiveObject("VisualStudio.DTE.8.0") as EnvDTE80.DTE2;

Best Regards,
Dustin Campbell
Developer Express Inc.
Notre Poubelle - 19 Sep 2006 21:15 GMT
That's great Dustin!  I will try this and let you know if it works.  One
final question (I hope): what if I have more than once instance of Visual
Studio running?  Is there a way to specify which instance to get using
GetActiveObject or some similar API?  If not, do you know which instance will
be retrieved (e.g. the last one to have focus, the last one registered in the
ROT)?

Thanks,
Notre
Dustin Campbell - 20 Sep 2006 12:48 GMT
Hi Notre,

Marshal.GetActiveObject is essentially a wrapper around the GetActiveObject
method from oleaut32.dll (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/automat/html/a2
76e30c-6a7f-4cde-9639-21a9f5170b62.asp
).
It's not clear from the documentation but I'd bet that you get back the last
object registered in the ROT.

If you start your instance of Visual Studio via COM automation, you can be
certain that you are getting the correct automation interface. Here's a C#
example:

System.Type dteType = System.Type.GetTypeFromProgID("VisualStudio.DTE.8.0");
DTE2 dte = Activator.CreateInstance(dteType, true) as DTE2;

Best Regards,
Dustin Campbell
Developer Express Inc
Notre Poubelle - 20 Sep 2006 17:36 GMT
Thanks Dustin!  I ended up calling WaitForInputIdle.  That solved half my
problem.  The second half seemed to be related to a type constructor in my VS
package which wasn't getting reliably called (I'm doing some interop work, so
it may be related to that).  I moved the code out of the type constructor and
this seemed to solve the problem.

I think I may go back and revisit how I'm launching VS, however, to use the
suggestion you gave in your last post.

Thanks again for the great help!
Notre

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.