简体   繁体   English

从Win Form应用程序运行SLN文件(Visual Studio解决方案)

[英]Run SLN file (visual studio solution) from win form application

I have a list of solutions items in ContextMenuStrip and I want to run selected one. 我在ContextMenuStrip中有一个解决方案项列表,我想运行选定的项。

I have a mouse event set and I have the full path of the directory + file name. 我设置了一个鼠标事件,并且具有目录+文件名的完整路径。

I want to run the file and that will open it on visual studio. 我想运行该文件,这将在Visual Studio上将其打开。

I tried to use the action of 我试图用

Process.Start(pathAndFileName);

when the pathAndFileName = D:\\Code\\MyRepoName\\Solutions\\TEST\\TEST_1.sln 当pathAndFileName = D:\\ Code \\ MyRepoName \\ Solutions \\ TEST \\ TEST_1.sln

this will open the windows 10 select program to run for file and Visual Studio is not in the list, but yet is set to be default for this files. 这将打开Windows 10选择程序以运行该文件,并且Visual Studio不在列表中,但已设置为该文件的默认程序。

private void ContextMenuStrip2_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
{
    string pathAndFileName = ((ToolStripMenuItem)e.ClickedItem).ToString();
    Process.Start(pathAndFileName);
}

run result 运行结果

您将需要启动Visual Studio(devenv.exe)并将解决方案作为参数提供,例如:

devenv.exe path\to\your\solution.sln

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在 Visual Studio 2019 中更新 .sln(解决方案)文件 - How to update .sln (solution) file within Visual Studio 2019 以编程方式获取与Visual Studio解决方案文件(* .sln)中的GUID相匹配的Assembly GUID - Getting Assembly GUID programmatically that matches that in Visual studio solution file (*.sln) 有什么方法可以先在Visual Studio 2017中创建空白解决方案(.sln)文件,然后添加项目? - Is there any way to create a blank solution (.sln) file first in Visual Studio 2017 and then add projects? 从WPF / Win Form应用程序连接到Win CE设备,而无需安装Visual Studio - Connect to Win CE device From WPF/Win Form Application Without Installing Visual Studio 在Visual Studio中将解决方案.sln文件存储在哪里? - Where to store solutions .sln file in Visual Studio? Visual Studio Win表单 - Visual Studio Win Form OSX 上的 Visual Studio Code 如何导入 sln/csproj 并运行? - How can Visual Studio Code on OSX import sln/csproj and run? 使用Microsoft.Build名称空间从Visual Studio .sln文件中获取项目列表 - Get list of projects from Visual Studio .sln file using Microsoft.Build namespace 无法在Visual Studio解决方案的调试文件夹中运行应用程序? - Can't run application in debug folder of Visual Studio Solution? 如何以编程方式在当前打开的Visual Studio IDE中打开.sln文件? - How to open a .sln file in the current open Visual Studio IDE programmatically?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM