views:

29

answers:

2

I'm writing a custom WPF Start Page for VS2010. I have it displaying a list of common solutions used by me in a View.

Now, I want to open the Solution in VS when selected.

Any ideas? I'm looking at the DTE stuff, but having very little success. Before I dig too deeply, is DTE the right way forward, or is there another way?

A: 

Can't you simply run it with the path to the solution as the argument?

Something like:

ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.FileName = vsdir;
startInfo.Arguments = pathtosolution;
Process.Start(startInfo);

(if I understand you right)

Blam
No, because I'm already in Visual Studio, I don't want to spawn a new instance.
DaveShaw
Oh right sorry, well glad to see you've found your answer :)
Blam
A: 

I found the solution.

In the Utilities class generated by the Visual Studio Template there is the following static method:

public static DTE2 GetDTE(object dataContext)
{
    ICustomTypeDescriptor typeDescriptor = dataContext as ICustomTypeDescriptor;
    Debug.Assert(typeDescriptor != null, "Could not get ICustomTypeDescriptor from dataContext. Was the Start Page tool window DataContext overwritten?");
    PropertyDescriptorCollection propertyCollection = typeDescriptor.GetProperties();
    return propertyCollection.Find("DTE", false).GetValue(dataContext) as DTE2;
}

By passing in the DataContext from my Control into the GetDTE() method I can do this:

var dte = Utilities.GetDTE(dataContext);
dte.Solution.Open(fullPathToSolution);
DaveShaw