Microsoft KB Archive/889831

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

Article ID: 889831

Article Last Modified on 12/11/2006

-

APPLIES TO


 * Microsoft Visual C# .NET 2003 Standard Edition
 * 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:

http://msdn2.microsoft.com/en-us/library/9eeb383s.aspx



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 &quot;More Information&quot; section.



STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the &quot;Applies to&quot; section.



Steps to reproduce the behavior
  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;

}

}  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

  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

}

}  At a command prompt, type the following command to compile the code that is in step 3:

csc /reference:a.dll Test.cs



Keywords: kbdev kbtshoot kbprb KB889831

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.