BUG: EnvDTE.Project.CodeModel doesn't retrieve attributes in the AssemblyInfo file

Author: Carlos J. Quintero (Microsoft MVP) Applies to: Microsoft Visual Studio .NET 2002
Date: July 2009   Microsoft Visual Studio .NET 2003
      Microsoft Visual Studio 2005
      Microsoft Visual Studio 2008


When you iterate the code elements of a project code model using EnvDTE.Project.CodeModel.CodeElements, the attributes in the AssemblyInfo are not retrieved.

This happens with C# projects in all Visual Studio versions and with VB.NET projects in Visual Studio .NET 2002/2003. It works fine with VB.NET projects in Visual Studio 2005 and higher.

More Information

Steps to reproduce the problem:

  • Create a Class Library project.
  • Create and run the following macro, which shows the attributes in the code model:
Language: VB.NET   Copy Code Copy Code (IE only)
   Sub GetCodeElements()


   End Sub

   Sub GetCodeElements(ByVal codeElements As CodeElements)

      For Each codeElement As CodeElement In codeElements

         Select codeElement.Kind

            Case vsCMElement.vsCMElementNamespace

               GetCodeElements(CType(codeElement, CodeNamespace).Members)

            Case vsCMElement.vsCMElementAttribute


         End Select


   End Sub

As a workaround, you can locate the AssemblyInfo file and use its EnvDTE.ProjectItem.FileCodeModel.

Related articles

Go to the 'Visual Studio Extensibility (VSX)' web site for more articles like this (Articles section)