BUG: The Visual Basic .NET compiler may stop responding when you try to build a project in Visual Studio .NET (831489)



The information in this article applies to:

  • Microsoft Visual Basic .NET (2003)
  • Microsoft Visual Basic .NET (2002)

SYMPTOMS

When you try to build a Microsoft Visual Basic .NET project in Microsoft Visual Studio .NET, the Visual Basic .NET compiler may stop responding. You may receive the following error message:
Visual Basic .NET compiler is unable to recover from the following error: System Error &Hc0000005& (Visual Basic internal compiler error)

Save your work and restart Visual Studio .NET.

CAUSE

This bug occurs if your Visual Basic .NET project contains a file that uses the DirectCast keyword to pass an argument to the constructor of an attribute. For example, this behavior occurs if your project contains a file that uses the following code:
<DefaultValueAttribute(DirectCast(Nothing, String))>

WORKAROUND

To work around this bug, follow these steps:
  1. Exit Visual Studio .NET after you receive the error message that is mentioned in the "Symptoms" section of this article.
  2. Restart Visual Studio .NET.
  3. Use the CType keyword in your code instead of the using the DirectCast keyword in your code.

    For example, your project may contain a file that uses the following code:
    <DefaultValueAttribute(DirectCast(Nothing, String))>
    Replace this code with the following code:
    <DefaultValueAttribute(CType(Nothing, String))>
    The new code uses the CType keyword instead of the DirectCast keyword.

STATUS

Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.

MORE INFORMATION

Steps to Reproduce the Behavior

To reproduce the behavior that is mentioned in the "Symptoms" section of this article, follow these steps:
  1. Start Visual Studio .NET.
  2. Use Visual Basic .NET to create a Console Application project.

    By default, the Module1.vb file is created.
  3. In Module1.vb, locate the following code:
    Module Module1
  4. Add the following code before the code that you located in step 3:
    Imports System.ComponentModel
  5. In Module1.vb, locate the following code:
    End Sub
  6. Add the following code after the code that you located in step 5:
    <DefaultValueAttribute(DirectCast(Nothing, String))> _
    Private ReadOnly Property Prop() As Integer
       Get
       End Get
    End Property
  7. Build your application.

    Notice the following output in the build window:Preparing resources...
    Updating references...
    Performing main compilation...The Visual Basic .NET compiler stops responding.
  8. On the Build menu, click Cancel to stop trying to build your application.
  9. On the File menu, click Close.

    You receive the error message that is mentioned in the "Symptoms" section of this article.

REFERENCES

For more information, visit the following Microsoft Web sites:

Modification Type:MinorLast Reviewed:2/9/2006
Keywords:kbvs2005swept kbvs2005doesnotapply kbvs2002sp1sweep kbProgramming kbIDEProject kbCompiler kbSample kberrmsg kbcode kbbug KB831489 kbAudDeveloper