Where is “Set as Startup” defined and persisted in C# winforms solutions?

北战南征 提交于 2020-01-13 11:35:10

问题


I don't see it in the .sln file, which is what I expected.


回答1:


Which project is the "startup" project only has any relevance for debugging, which means it's user metadata from the point of the solution and the projects. Regardless of which project is the "startup" project, the compiled code is the same.

Because of this, the information is stored as a user setting in the Solution User Options file (solution.suo) which accompanies the Solution file (solution.sln). The .suo file "Records all of the options that you might associate with your solution so that each time you open it, it includes customizations that you have made" according to MSDN.

The .suo file is a binary file. If you want to read or change it programatically, you have to use IVsPersistSolutionOpts.LoadUserOptions from the Microsoft.VisualStudio.Shell.Interop namespace.




回答2:


It's in the Solutions User Options (.suo) file, which gets created next to the .sln file.




回答3:


It seems that the first item in the solution's sln file is, by default, the startup project. So, you could manually edit the sln file to make your project the first project in the solution. Then, a user can override that by selecting a different project to be startup.



来源:https://stackoverflow.com/questions/694685/where-is-set-as-startup-defined-and-persisted-in-c-sharp-winforms-solutions

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!