且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

无论如何,加载解决方案时是否要告诉Visual Studio不要打开所有文档?

更新时间:2022-03-22 05:41:22

在关闭解决方案之前,您可以通过为EnvDTE.BeforeClosing事件添加处理程序来自动化关闭所有文件的过程-这将被调用VS退出时.

You can automate the process of closing all the files prior to closing a solution by adding a handler for the BeforeClosing event of EnvDTE.SolutionEvents -- this will get invoked when VS is exiting.

在VS2005中,将以下内容添加到EnvironmentEvents宏模块将关闭所有打开的文档:

In VS2005, adding the following to the EnvironmentEvents macro module will close all open documents:


    Private Sub SolutionEvents_BeforeClosing() Handles SolutionEvents.BeforeClosing
        DTE.ExecuteCommand("Window.CloseAllDocuments")
    End Sub

Visual Studio 2008似乎支持相同的事件,所以我相信这也可以使用.

Visual Studio 2008 appears to support the same events so I'm sure this would work there too.

如果可以的话,我确定您也可以在处理程序中删除项目的.suo文件,但是您可能希望使用AfterClosing事件.

I'm sure you could also delete the .suo file for your project in the handler if you wanted, but you'd probably want the AfterClosing event.