-
Notifications
You must be signed in to change notification settings - Fork 2
Test With...VS SDK
Jamie Cansdale edited this page Jul 24, 2018
·
4 revisions
This command allows ad-hoc methods to execute inside the running Visual Studio process and access automation objects, services and MEF components.
- Add a reference to
EnvDTE.dll - Create the following method
void Hello(DTE dte)
{
Console.WriteLine($"Hello, {dte.Name}!");
}- Right-click inside
HelloandTest With > In-Proc (VS SDK)
You should see
------ Test started: Assembly: EnvDteTests.dll ------
Hello, Microsoft Visual Studio!
1 passed, 0 failed, 0 skipped, took 0.13 seconds (Ghost).
You can also access the DTE2 object from EnvDTE80.dll like this:
void Hello(DTE2 dte)
{
dte.ToolWindows.CommandWindow.Parent.Activate();
dte.ToolWindows.CommandWindow.SendInput("Help.About", false);
}If you need to start on the UI thread, you can use the [STAThread] attribute:
[STAThread]
void RunOnUIThread()
{
Console.WriteLine(Thread.CurrentThread.GetApartmentState());
}