Project 接口

更新:2007 年 11 月

表示集成开发环境 (IDE) 中的项目。

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

语法

声明
<GuidAttribute("866311E6-C887-4143-9833-645F5B93F6F1")> _
Public Interface Project
用法
Dim instance As Project
[GuidAttribute("866311E6-C887-4143-9833-645F5B93F6F1")]
public interface Project
[GuidAttribute(L"866311E6-C887-4143-9833-645F5B93F6F1")]
public interface class Project
public interface Project

备注

解决方案中的每个项目都有一个项目自动化接口。少数情况下,这是泛型未建模项目的实现,它返回项目的名称。

环境中每个带有项目的工具都有一个 Project 对象。

使用 DTE.Solution.Item 或特定语言的对象(如 DTE.VBProjects.Item 或 DTE.VCProjects.Item)来引用此对象。

说明:

项目特定的对象(如 DTE.VBProjects.Item 和 DTE.VCProjects.Item)位于其他程序集中。Visual Basic 和 Visual C# 项目对象位于 VSLangProj 中,而 Visual C++ 项目对象位于 Microsoft.VisualStudio.VCProjectEngine 中。有关针对项目特定的对象进行编程的更多信息,请参见扩展 Visual Basic 和 Visual C# 项目Visual C++ 项目模型

示例

Sub ProjectExample()
' This function creates a solution and adds a Visual Basic Console
' project to it. 
   Dim soln As Solution2
   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 Visual Basic Console application project. 
' Adjust the save path as needed.
   Dim fileN As String
   fileN = soln.GetProjectTemplate("ConsoleApplication.zip", "VisualBasic")
   proj = soln.AddFromTemplate(fileN, "c:\temp2", "My New Project", True)
   
' Save the new solution
   soln.SaveAs("c:\temp2\newsolution.sln")
   msg = "Created new solution: " & soln.FullName
   MsgBox(msg)
End Sub

另请参见

参考

Project 成员

EnvDTE 命名空间

其他资源

控制项目和解决方案