Microsoft KB Archive/820656

= BUG: &quot;Type  is not defined&quot; error message when you try to inherit a protected nested class in Visual Basic .NET =

Article ID: 820656

Article Last Modified on 5/16/2007

-

APPLIES TO


 * Microsoft Visual Basic .NET 2003 Standard Edition
 * Microsoft Visual Basic .NET 2002 Standard Edition

-



SYMPTOMS
When you try to inherit a protected nested class in Visual Basic .NET, you receive the following compilation error message:

Type  is not defined



WORKAROUND
To work around this problem, change the protected nested class to a public nested class. When you inherit the nested class, qualify the nested class with a parent class. The following code demonstrates the workaround for the example that is listed in the &quot;More Information&quot; section of this article: Option Explicit On Option Strict On

Public Class OuterBase Public Sub New 'Constructor End Sub 'Modify this class as public. Public Class InnerBase Private a As Integer

Public Sub New 'Constructor End Sub End Class End Class

Public Class OuterDerived Inherits OuterBase

Dim ia As OuterBase.InnerBase 'Qualify the Nested class with its Parent. Protected Class InnerDerived Inherits OuterBase.InnerBase

Public Sub New 'Constructor End Sub End Class

Public Sub New 'Constructor End Sub End Class



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



Steps to Reproduce the Behavior
 Start Microsoft Visual Studio .NET. On the File menu, point to New, and then click Project. Click Visual Basic Projects under Project Types, click Class Library under Templates, and then click OK. By default, Class1 is created.  Paste the following code in class1: Option Explicit On Option Strict On

Public Class OuterBase Public Sub New 'Constructor End Sub 'Define a protected class. Protected Class InnerBase Private a As Integer

Public Sub New 'Constructor End Sub End Class End Class

Public Class OuterDerived Inherits OuterBase

Dim ia As OuterBase.InnerBase 'Inherit protected nested class. Protected Class InnerDerived Inherits InnerBase

Public Sub New 'Constructor End Sub End Class

Public Sub New 'Constructor End Sub End Class  On the Build menu, click Build Solution. You receive the compilation error message that is listed in the &quot;Symptoms&quot; section of this article.</ol>

<div class="references_section">