我正在为VS2010编写自定义WPF起始页。我在视图中显示了我使用的常用解决方案列表。
现在,我想在选择时在VS中打开解决方案。
有什么想法吗?我正在看DTE的东西,但收效甚微。在我深入挖掘之前,DTE是正确的前进方向,还是有另一种方式?
答案 0 :(得分:3)
我找到了解决方案。
在Visual Studio模板生成的Utilities类中,有以下静态方法:
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;
}
通过将DataContext从我的Control传入GetDTE()方法,我可以这样做:
var dte = Utilities.GetDTE(dataContext);
dte.Solution.Open(fullPathToSolution);
答案 1 :(得分:0)
难道你不能简单地以解决方案的路径作为参数运行吗?
类似的东西:
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.FileName = vsdir;
startInfo.Arguments = pathtosolution;
Process.Start(startInfo);
(如果我理解你的话)