_Solution 接口

表示集成开发环境 (IDE) 中所有的项目和解决方案属性。 有关此功能,请参考 Solution。 不要从此类实例化。

命名空间:  EnvDTE
程序集:  EnvDTE(在 EnvDTE.dll 中)

语法

声明
<GuidAttribute("26F6CC4B-7A48-4E4D-8AF5-9E960232E05F")> _
Public Interface _Solution _
    Inherits IEnumerable
[GuidAttribute("26F6CC4B-7A48-4E4D-8AF5-9E960232E05F")]
public interface _Solution : IEnumerable
[GuidAttribute(L"26F6CC4B-7A48-4E4D-8AF5-9E960232E05F")]
public interface class _Solution : IEnumerable
[<GuidAttribute("26F6CC4B-7A48-4E4D-8AF5-9E960232E05F")>]
type _Solution =  
    interface 
        interface IEnumerable 
    end
public interface _Solution extends IEnumerable

_Solution 类型公开以下成员。

属性

  名称 说明
公共属性 AddIns 获取 AddIns 集合,它包含与解决方案关联的所有当前可用的外接程序。
公共属性 Count 获取一个值,该值指示集合中对象的数目。
公共属性 DTE 获取顶级扩展性对象。
公共属性 Extender 如果请求的扩展程序对象可用于此对象,则获取该扩展程序对象。
公共属性 ExtenderCATID 获取对象的扩展程序类别 ID (CATID)。
公共属性 ExtenderNames 获取对象的可用扩展程序的列表。
公共属性 FileName 基础结构。 仅由 Microsoft 内部使用。
公共属性 FullName 获取对象文件的完整路径和名称。
公共属性 Globals 获取 Globals,它包含可以保存在解决方案 (.sln) 文件、项目文件或用户的配置文件数据中的外接程序值。
公共属性 IsDirty 基础结构。 仅由 Microsoft 内部使用。
公共属性 IsOpen 确定解决方案是否打开。
公共属性 Parent 获取 _Solution 的直接父对象。
公共属性 Projects 获取解决方案中当前项目的集合。
公共属性 Properties 获取与 _Solution 有关的所有属性的集合。
公共属性 Saved 如果对象自上次保存或打开后没有经过修改,则返回 true。
公共属性 SolutionBuild 获取解决方案的 SolutionBuild 对象,该对象表示位于解决方案级的生成自动化模型的根。
公共属性 TemplatePath 获取指定类型的项目的模板所在目录的完整路径和名称。

页首

方法

  名称 说明
公共方法 AddFromFile 基于已存储在系统中的项目文件,将项目添加到解决方案。
公共方法 AddFromTemplate 将现有项目文件及其包含的任何项或子目录复制到指定位置,并将其添加到解决方案。
公共方法 Close 关闭当前解决方案。
公共方法 Create 在指定的目录中创建具有指定名称的空解决方案。
公共方法 FindProjectItem 在项目中定位项。
公共方法 GetEnumerator 返回集合中项的枚举。
公共方法 Item 返回 Projects 集合中的一个 Project 对象。
公共方法 Open 在指定视图中打开解决方案。
公共方法 ProjectItemsTemplatePath 返回指定项目类型的项目项模板的位置。
公共方法 Remove 从解决方案中移除指定的项目。
公共方法 SaveAs 保存解决方案。

页首

备注

Solution 对象是 IDE 当前实例中的所有项目以及所有解决方案范围的属性(如生成配置)的集合。 Solution 对象对于每个项目都包含一个对应的项目元素,不管该项目是打包项目、子项目,还是顶级项目。

使用 DTE.Solution 引用此对象。 若要引用虚项目(如 MiscFiles 或 SolutionItems),请使用 Solution.Item(EnvDTE.Constants.vsProjectKindMisc) 或 Solution.Item(EnvDTE.Constants.vsProjectKindSolutionItems)。

示例

Sub SolutionExample()
   'This function creates a solution and adds a Visual Basic Console
   'project to it. 
   Dim soln As Solution
   Dim proj As Project
   Dim msg As String

   'Create a reference to the solution.
   soln = DTE.Solution

   ' Create a new solution.
   soln.Create("c:\temp2", "MyNewSolution")

   ' Create a new VB project from a template. 
   ' Adjust the template path and save path as needed.
   proj = soln.AddFromTemplate("<template path>\ConsoleApplication.vbproj", "c:\temp2", "My New Project", True)
   ' Save the new solution and project.
   soln.SaveAs("c:\temp2\newsolution.sln")
   msg = "Created new solution: " & soln.FullName & vbCrLf
   msg = msg & "Created new project: " & proj.Name
   MsgBox(msg)
End Sub

请参阅

参考

EnvDTE 命名空间