0 out of 2 rated this helpful - Rate this topic

Compiler Warning (level 1) CS3003

Type of 'variable' is not CLS-compliant

A public, protected, or protected internal variable must be of a type that is compliant with the Common Language Specification (CLS). For more information on CLS Compliance, see Writing CLS-Compliant Code and Common Language Specification.

The following example generates CS3003:

// CS3003.cs

[assembly:System.CLSCompliant(true)]
public class a
{
    public ushort a1;   // CS3003, public variable
    public static void Main()
    {
    }
}
Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
Bogus Warning
The base type of ushort is UInt16 which is CLS complient.  All unsigned stuctures are generating this warnings even though they are valid.

Edit by JeppeSN: No, UInt16 is not CLS compliant: http://msdn.microsoft.com/en-us/library/system.uint16.aspx. But it is still cool to use, just don't mark your assembly as CLS compliant. So find the file with [assembly: CLSCompliant(true)] in it, and remove that attribute. Who cares about VB, anyway? /JeppeSN