CLS Compliance Issue in VB.NET

What's not CLS-compliant about the simple class below?

I am getting a warning that my derived class is not CLS compliant because it inherits from the below class, which is not CLS compliant (apparently).

Public MustInherit Class BaseModel

    Protected MustOverride Sub SetIDValue(nValue As Long)

End Class

      

Yes - above is the complete class code.

Here are the complete files for both the base class and the derived class:

Base class:

Imports System.ComponentModel.DataAnnotations

Namespace Core

    Public MustInherit Class BaseModel

        Protected MustOverride Sub SetIDValue(nValue As Long)

    End Class

End Namespace

      

Derived class:

Imports Snap.Core
Imports System.ComponentModel.DataAnnotations


Public Class SystemValueModel
    Inherits BaseModel

    Public Sub New()

    End Sub


    Public ID_SystemValue As Long

    <Required()> <StringLength(25)>
    Public Token As String

    <Required()> <StringLength(255)>
    Public Value As String

    Protected Overrides Sub SetIDValue(nValue As Long)
        'Nada
    End Sub

End Class

      

+3


source to share


1 answer


I was able to reproduce this error by enabling code analysis in the assembly and using "All Microsoft Rules". To mark BaseModel

as CLS Compliant, add <Assembly: CLSCompliant(True)>

before Namespace Core

. You can find more information here .



0


source







All Articles