Dönüş türü erişilebilir olmadığından '<methodname>' bu bağlamda erişilebilir değil

Çağırma deyiminden erişemeyeceğiniz dönüş türüne sahip bir işlev çağırdınız. Örneğin, aşağıdaki kodda , dönüş türü PrivateTypesınıfında TestClasserişim değiştiricisi ile Private bildirildiği için PublicMethod öğesinden Main çağrısı başarısız olur. Bu nedenle, içinde PrivateType erişilebilen bağlam ile TestClasssınırlıdır.

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

Hata Kimliği: BC36665 ve BC36666

Bu hatayı düzeltmek için

  • Tür tanımı erişilebilir durumdaysa, erişim değiştiricisini olarak Private Publicdeğiştirin.

  • erişiminiz varsa işlevin dönüş türünü değiştirin.

  • Erişilebilir bir tür döndüren bir yöntem veya uzantı yöntemi yazın.

Ayrıca bkz.