开发者

Why is my function not CLS-compliant?

I'm getting the following warning message...

Return type of开发者_运维知识库 function 'ConnectionNew' is not CLS-compliant.

...for this function:

Public Function ConnectionNew(ByVal DataBaseName As String) As MySqlConnection
      Dim connection As MySqlConnection = Nothing
      connection = getConnection(DataBaseName())
      Return connection
End Function

What does this message mean, and how can I fix it?


It is because you are returning an object of a type that's not CLS compliant. Nothing you can do about that, you didn't write the type. Just acknowledge that you know that it isn't compliant, it isn't otherwise likely to cause any problems. Unless you use the function in another language that doesn't support all the .NET types. Fix:

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜