|Important||This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer|
An object providing project-level access to any contained code element.
Assembly: Microsoft.VisualStudio.VCCodeModel (in Microsoft.VisualStudio.VCCodeModel.dll)
The object provides code model functionality to various languages supported by Visual Studio (including Visual C++) at the project level.
Primarily, this object is used to find any code element accessible within a project (given a fully-qualified name). In addition, the object specifies the programming language in which the project is written.
A large part of the functionality of this object is provided by the Visual Studio CodeModel2 object.
When using a object within a managed project, include Microsoft.VisualStudio.VCCodeModel.dll as a reference. For more information about adding references to a managed project, see How to: Add or Remove References in Visual Studio (Visual Basic).
See How to: Compile Example Code for Visual C++ Code Model Extensibility for information about how to compile and run this sample.
This function returns the object representing the first project in a solution.
Function GetVCCodeModel() As VCCodeModel GetVCCodeModel = Nothing Dim codeModel As CodeModel Dim vcCodeModel As VCCodeModel Dim solution As Solution solution = DTE.Solution If (solution Is Nothing) Then MsgBox("A Solution is not open") Exit Function Else If (DTE.Solution.Count <> 0) Then codeModel = DTE.Solution.Item(1).CodeModel vcCodeModel = CType(codeModel, VCCodeModel) If (vcCodeModel Is Nothing) Then MsgBox("The first project is not a VC++ project.") Exit Function Else GetVCCodeModel = vcCodeModel End If End If End If End Function