I was able to reproduce this error by Enabling Code Analysis on Build and using "Microsoft All Rules".
To mark BaseModel
as CLS Compliant, add <Assembly: CLSCompliant(True)>
before Namespace Core
You can find more information here.
CLS compliance issue in VB.NET
-
07-03-2022 - |
Domanda
What is not CLS compliant about the simple class below?
I get the warning that my derived class is not CLS compliant, because it inherits from the class below, which is not CLS compliant (apparently).
Public MustInherit Class BaseModel
Protected MustOverride Sub SetIDValue(nValue As Long)
End Class
Yes - the above is the full code of the class.
Here are full files for both the base class and 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
Nessuna soluzione corretta
Altri suggerimenti
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow