The strange case of InvalidCastException using EditPoint.FindPattern with Visual Studio Database Projects

Many months ago I reported to Microsoft through Microsoft Connect an InvalidCastException that happened when using the EditPoint.FindPattern with .sql files of a database project of Visual Studio 2008 Team Suite (or VS 2008 Edition for DB Professionals) Beta 2:

EditPoint.FindPattern causes InvalidCastException on SQL editor of VSTS for DB Professional projects

As I reported, the problem didn’t happen in Visual Studio 2005 (at the time of that report), so apparently the bug was introduced in Visual Studio 2008 Beta 2. Fortunately Microsoft fixed the bug for VS 2008 RTM, so I thought the case was closed.

However, last week a customer of my MZ-Tools add-in reported that same problem but using VS 2005. How could that be if the problem didn’t happen at that time? In fact the problem didn’t happen today with VS 2005 SP1 and the VS 2005 Vista update on my computer. Reviewing the list of updates that the customer had installed, I had all of them but this one:

Microsoft® Visual Studio® 2005 Team Edition for Database Professionals Service Release 1

I installed it, and bingo! The problem was reproduced. So, while VS 2005 SP1 works fine, that update, which was released after SP1, introduced the bug, that was included in VS 2008 Beta 2 and was fixed in VS 2008 RTM, but for VS 2005 users the bug remains there if they install that service release.