为对解决方案所做的更改提供事件。 使用此对象可以实现多种功能,有关此对象的文档,请参考 SolutionEventsClass。
命名空间:  EnvDTE
程序集:  EnvDTE(在 EnvDTE.dll 中)
语法
声明
<GuidAttribute("BF8BBF37-5415-46A9-940D-594CAD9DEC26")> _
Public Interface SolutionEvents _
    Inherits _SolutionEvents, _dispSolutionEvents_Event
[GuidAttribute("BF8BBF37-5415-46A9-940D-594CAD9DEC26")]
public interface SolutionEvents : _SolutionEvents, 
    _dispSolutionEvents_Event
[GuidAttribute(L"BF8BBF37-5415-46A9-940D-594CAD9DEC26")]
public interface class SolutionEvents : _SolutionEvents, 
    _dispSolutionEvents_Event
[<GuidAttribute("BF8BBF37-5415-46A9-940D-594CAD9DEC26")>]
type SolutionEvents =  
    interface
        interface _SolutionEvents
        interface _dispSolutionEvents_Event
    end
public interface SolutionEvents extends _SolutionEvents, _dispSolutionEvents_Event
SolutionEvents 类型公开以下成员。
方法
页首
事件
| 名称 | 说明 | |
|---|---|---|
| .gif) | AfterClosing | 基础结构。仅由 Microsoft 内部使用。 (继承自 _dispSolutionEvents_Event。) | 
| .gif) | BeforeClosing | 基础结构。仅由 Microsoft 内部使用。 (继承自 _dispSolutionEvents_Event。) | 
| .gif) | Opened | 基础结构。仅由 Microsoft 内部使用。 (继承自 _dispSolutionEvents_Event。) | 
| .gif) | ProjectAdded | 基础结构。仅由 Microsoft 内部使用。 (继承自 _dispSolutionEvents_Event。) | 
| .gif) | ProjectRemoved | 基础结构。仅由 Microsoft 内部使用。 (继承自 _dispSolutionEvents_Event。) | 
| .gif) | ProjectRenamed | 基础结构。仅由 Microsoft 内部使用。 (继承自 _dispSolutionEvents_Event。) | 
| .gif) | QueryCloseSolution | 基础结构。仅由 Microsoft 内部使用。 (继承自 _dispSolutionEvents_Event。) | 
| .gif) | Renamed | 基础结构。仅由 Microsoft 内部使用。 (继承自 _dispSolutionEvents_Event。) | 
页首
备注
SolutionEvents 对象可能超出范围,进行垃圾回收后关闭解决方案。 若要保留对此对象的引用,请在您实现解决方案事件处理程序的类中声明私有变量。
示例
public class Connect : IDTExtensibility2
{
    private SolutionEvents _solnEvents;
    public void OnConnection(object application, ext_ConnectMode connectMode, object addInInst, ref Array custom)
    {
        _applicationObject = (DTE2)application;
        _addInInstance = (AddIn)addInInst;
        _solnEvents = _applicationObject.Events.SolutionEvents;
        _solutionBeforeClosingEventHandler = new _dispSolutionEvents_BeforeClosingEventHandler(this.SolutionBeforeClosing);
        _solnEvents.BeforeClosing += _solutionBeforeClosingEventHandler;
    }
    private _dispSolutionEvents_BeforeClosingEventHandler _solutionBeforeClosingEventHandler
    private void SolutionBeforeClosing()
    {
        System.Windows.Forms.MessageBox.Show("SolutionBeforeClosing");
    }
}
.gif)