vb.net - 为什么我的函数不符合 CLS?

标签 vb.net warnings cls-compliant

我收到以下警告消息...

Return type of function 'ConnectionNew' is not CLS-compliant.



...对于这个功能:
Public Function ConnectionNew(ByVal DataBaseName As String) As MySqlConnection
      Dim connection As MySqlConnection = Nothing
      connection = getConnection(DataBaseName())
      Return connection
End Function

此消息是什么意思,我该如何解决?

最佳答案

这是因为您要返回一个不符合 CLS 的类型的对象。您对此无能为力,您没有编写类型。只需承认您知道它不合规,否则不太可能导致任何问题。除非您在不支持所有 .NET 类型的另一种语言中使用该函数。使固定:

<CLSCompliant(False)> _
Public Function ConnectionNew(ByVal DataBaseName As String) As MySqlConnection
   '' etc...
End Function

关于vb.net - 为什么我的函数不符合 CLS?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7065142/

相关文章:

mysql - 禁用 VB.NET MySQL 连接的 SSL 要求

r - 通过正则表达式筛选的选择性preventWarnings()

c# - NUnit TestCase - 作为属性参数的数组不符合 CLS

.net - .NET 中的 CIL、CLS 和 CTS

.net - BCL 与 CLS 有何关系?

vb.net - 如何在 VB.NET 1.1 中为可选参数分配空值

vb.net - 我在使用 FileSystemWatcher [vb.net] 时遇到问题

mysql - 在测试数据库和生产数据库之间切换?

c - 警告 : Implicit declaration error

ios - Xcode 7 : Warnings when API version is higher than target version?