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?

DaveShaw
  • 52,123
  • 16
  • 112
  • 141

2 Answers2

3

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
  • 52,123
  • 16
  • 112
  • 141
0

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
  • 2,888
  • 3
  • 25
  • 39