更新:2007 年 11 月
所调用的函数具有无法从调用语句中访问的返回类型。例如,在下面的代码中,从 Main 中调用 PublicMethod 失败,因为返回类型 PrivateType 是在类 TestClass 中使用 Private 访问修饰符声明的。因此,可以访问 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。
如果能够访问该函数,请更改该函数的返回类型。
编写一个返回可访问类型的方法或扩展方法。