Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Base type is not CLS-compliant, what reasons of this warning?

I have got warning from subject on one of my classes. Actually class is very simple, just an inheritor of my generic base type. Also I have some other inheritors from that generic class across the solution, and there are no such warnings.

What could be the reason(s) of this? Compiler does not give any clues of why base type is not CLS-compliant

like image 746
DarkDeny Avatar asked Oct 25 '10 08:10

DarkDeny


People also ask

What does CLS compliant mean?

Being CLS compliant means that you can write code that can be consumed by any language that can be compiled and run on the CLR. But CLS compliance is not required, giving you the flexibility in cases where CLS compliance would be hard or impossible to do.

Which is not a CLS compliant language?

CLS compliance has to do with interoperability between the different . NET languages. The property is not CLS compliant, because it starts with an underscore and is public (note: protected properties in a public class can be accessed from outside the assembly).


2 Answers

You probably have [assembly:CLSCompliant(true)] somewhere in that specific project. This triggers the compiler to check all types to be CLS compliant. You can override this for a type or method or something with [CLSCompliant(false)].

like image 125
Pieter van Ginkel Avatar answered Sep 23 '22 18:09

Pieter van Ginkel


I guess you have a derived type marked as CLSCompliant but the base isn't.

Writing CLS Compliant Code The canonical example is using a UInt32 which is not part of the Common Language Specification (CLS) - hence you need to use Int64 to be CLS compliant or remove the attribute (declare yourself non-cls compliant).

Need more code to identify the offending line of code. More info on the error you're getting.

like image 38
Gishu Avatar answered Sep 24 '22 18:09

Gishu