Another VB.NET note (The BuildRules add-in)

On another VB.NET note, for anyone using the BuildRules tool included in the Microsoft Visual Studio .Net 2003 Automation Samples and have noticed that when you have a reporting project in your solution the BuildRules tree doesn't populate itself, the bug is essentially the same bug as the one I fixed in VBCommenter.  There's a "foreach (project in solution.projects)" or some such loop in the BuildRules code, which fails somewhat silently when a reporting services project is in the solution.  If you change it to an indexed loop going from 1 to the count of the Solution.Projects.Count property (yes, it really is a one-based array) and get the project using the Projects.Item(index) property, it will work again.  This appears to have something to do with the COM interface to VS.NET and its implementation of the COM equivalent of IEnumerable.GetEnumerator (NewEnum? Sorry, I wasn't a COM guy before .NET) method, which fails in this case.

Specifics (DISCLAIMER: this is mostly untested code, but should work):

On line 266 of the RulesFrm.vb file, you'll find this:

  266         For Each project In applicationObject.Solution.Projects

  267             Dim globals As EnvDTE.Globals

  268             Try

  269                 globals = project.Globals

  270             Catch

  271                 globals = Nothing

  272             End Try

  273 

  274             If Not (globals Is Nothing) Then

  275                 projectNode = preBuildNode.Nodes.Add(project.Name)

  276                 projectNode.Tag = project

  277                 projectNode = postBuildNode.Nodes.Add(project.Name)

  278                 projectNode.Tag = project

  279             End If

  280         Next

If you change it to read:

  266         For i As Integer = 1 To applicationObject.Solution.Projects.Count

  267             project = applicationObject.Solution.Projects.Item(i)

  268             Dim globals As EnvDTE.Globals

  269             Try

  270                 globals = project.Globals

  271             Catch

  272                 globals = Nothing

  273             End Try

  274 

  275             If Not (globals Is Nothing) Then

  276                 projectNode = preBuildNode.Nodes.Add(project.Name)

  277                 projectNode.Tag = project

  278                 projectNode = postBuildNode.Nodes.Add(project.Name)

  279                 projectNode.Tag = project

  280             End If

  281 

  282         Next

It should fix the issue and allow you to use the BuildRules add-in with Reporting Services projects.  It seems strange, but it's true!

1 Comment

Comments have been disabled for this content.