You receive a "Total occurrences found: 0" message when you use the Find in Files dialog box in Visual Studio .NET or Visual Studio 2005 (884465)



The information in this article applies to:

  • Microsoft Visual Studio 2005 Professional Edition
  • Microsoft Visual Studio 2005 Standard Edition
  • Microsoft Visual Studio .NET (2003), Enterprise Architect Edition
  • Microsoft Visual Studio .NET (2003), Enterprise Developer Edition
  • Microsoft Visual Studio .NET (2003), Academic Edition
  • Microsoft Visual Studio .NET (2002), Professional Edition
  • Microsoft Visual Studio .NET (2002), Enterprise Architect Edition
  • Microsoft Visual Studio .NET (2002), Enterprise Developer Edition
  • Microsoft Visual Studio .NET (2002), Academic Edition

SYMPTOMS

In Microsoft Visual Studio .NET or in Microsoft Visual Studio 2005, when you perform a search by using the Find in Files dialog box, you notice that the search process returns no occurrences of your search phrase in the current document. The report in the Find Results window appears similar to the following: Find all "Search Phrase", Hidden, Block, Find Results 1, Current Document

Total occurrences found: 0
Note Search Phrase is a placeholder for the phrase that you are trying to locate in the document.

CAUSE

This behavior occurs because the Find dialog box uses block scope. The scope that is set in the Find dialog box also applies to the Find in Files dialog box.

WORKAROUND

To avoid this behavior, set the scope in the Find dialog box to Current document. To do this, follow these steps:
  1. Start Visual Studio .NET or Visual Studio 2005.
  2. Create a Visual C# Windows Application project.
  3. Open the code view of the Form1.cs form.
  4. Position the pointer on the following function. This function is located inside the Form1 function.
    InitializeComponent
  5. On the Edit menu, point to Find and Replace, and then click Find. The Find dialog box appears.
  6. Under Search, select Current document.

STATUS

This behavior is by design.

MORE INFORMATION

Steps to reproduce the behavior

  1. Start Visual Studio .NET or Visual Studio 2005.
  2. Create a Visual C# Windows Application project.
  3. Open the code view of the Form1.cs form.
  4. Position the pointer on the following function. This function is located inside the Form1 function.
    InitializeComponent
  5. Perform a search by using the Find in Files dialog box. To do this, follow these steps:
    1. On the Edit menu, point to Find and Replace, and then click Find in Files. The Find in Files dialog box appears.
    2. In the Find what box, type Dispose.
    3. In the Look in box, select Current Document.
    4. Click Find.
    The search occurrences appear in the Find Results window.
  6. Perform the same search by using the Find dialog box. To do this, follow these steps:
    1. On the Edit menu, point to Find and Replace, and then click Find. The Find dialog box appears.
    2. In the Find what box, type Dispose.
    3. Under Search, select Only:Form1().
    4. Click Find Next.
    You receive the following message: The specified text was not found.
  7. Repeat step 5.

    You notice the behavior that is mentioned in the "Symptoms" section.

REFERENCES

For more information about the Find dialog box and the Find in Files dialog box, visit the following Microsoft Developer Network (MSDN) Web sites:

Modification Type:MajorLast Reviewed:3/7/2006
Keywords:kbvs2005swept kbvs2005applies kbtshoot kbForms kbprb KB884465 kbAudDeveloper