반환 형식에 액세스할 수 없으므로 이 컨텍스트에서 '<methodname>'에 액세스할 수 없습니다.
업데이트: 2007년 11월
'<methodname>' is not accessible in this context because the return type is not accessible
호출 문에서 액세스할 수 없는 반환 형식을 사용하는 함수를 호출했습니다. 예를 들어 다음 코드의 Main에서 PublicMethod를 호출하면 실패합니다. 이는 반환 형식 PrivateType이 Private 액세스 한정자를 사용하여 TestClass 클래스에 선언되었으므로 PrivateType에 액세스할 수 있는 컨텍스트가 TestClass로 제한되기 때문입니다.
Class TestClass
Dim pT As New PrivateType
Private Class PrivateType
End Class
'' A corresponding error is returned in this line: 'PublicMethod
'' cannot expose 'PrivateType' in namespace 'ConsoleApplication1'
'' through class 'TestClass'.
'Public Function PublicMethod() As PrivateType
' Return Nothing
'End Function
End Class
Module Module1
Sub Main()
Dim tc As TestClass
'' This error occurs here, because the data type returned by
'' PublicMethod()is declared Private in class TestClass and
'' cannot be accessed from here.
'Console.WriteLine(tc.PublicMethod())
End Sub
End Module
오류 ID: BC36665 및 BC36666
이 오류를 해결하려면
형식 정의에 액세스할 수 있으면 액세스 한정자를 Private에서 Public으로 변경합니다.
반환 형식에 액세스할 수 있으면 함수의 반환 형식을 변경합니다.
액세스할 수 있는 형식을 반환하는 메서드나 확장 메서드를 작성합니다.