You receive an internal compiler error message when you compile a Visual C# .NET 2003 or a Visual C# 2005 project (889831)



The information in this article applies to:

  • Microsoft Visual C# .NET (2003)
  • Microsoft Visual C# 2005, Express Edition

SYMPTOMS

When you try to compile a Microsoft Visual C# .NET 2003 or Microsoft Visual C# 2005 project, you may receive an error message that is similar to the following:
error CS0583: Internal Compiler Error
In Microsoft Visual Studio 2005, you receive the following error message:
error CS0572: 'type' : cannot reference a type through an expression; try 'path_to_type' instead
For more information about this error message, visit the following Microsoft Developer Network (MSDN) Web site:

CAUSE

This problem occurs because you incorrectly tried to use a type name to access an instance member on a nested type instead of using a variable name.

RESOLUTION

To resolve this problem, use a variable name in the reference. For an example, see the "More Information" section.

STATUS

Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.

MORE INFORMATION

Steps to reproduce the behavior

  1. Paste the following code in Notepad, and then save the file as A.cs:
    public class Outer
    
    {
    
          public Outer.Nested NestedVar; 
    
     
    
          public class Nested
    
          {
    
                public int Field; 
    
          }
    
    }
  2. At a command prompt, type the following command to use the C# compiler (Csc.exe) to compile the code that is in step 1:

    csc.exe /target:library A.cs

  3. Paste the following code in Notepad, and save the file as Test.cs:
    class Test
    
    {
    
          static void Main()
    
          {
    
                Outer outer = new Outer();
    
                outer.Nested.Field = 0;       // Incorrect code
    
                // outer.NestedVar.Field = 0; // Correct Code
    
          }
    
    }
  4. At a command prompt, type the following command to compile the code that is in step 3:

    csc /reference:a.dll Test.cs


Modification Type:MajorLast Reviewed:1/18/2006
Keywords:kbDev kbtshoot kbprb KB889831 kbAudDeveloper