40
votes

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

4
Check that no methods or properties that are visible outside the class have the same spelling with only case to separate them, ex: Connection and connection. VB.NET does not differentiate between case and those properties would then be ambiguous.David Mårtensson

4 Answers

61
votes

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)].

4
votes

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.

0
votes

We are using MsBuildTasks and one thing we notices is that in the Common.targets file, CLSCompliant was set to true. This was setting that value in each of the AssemblyInfo files.

0
votes

put <AssemblyClsCompliant>false</AssemblyClsCompliant> in your .csproj file of your base project and the project who refer to it.