Why do I get the compiler warning
Identifier \'Logic.DomainObjectBase._isNew\' is not CLS-compliant
for the following code?
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). Although this will work if the property is accessed from C# it may not if it is accessed from other .NET languages that don't allow underscores at the start of property names, hence it is not CLS-compliant.
You are getting this compiler error, because somewhere in your code you have labelled your assembly as CLS compliant with a line something like this:
[assembly: CLSCompliant(true)]
Visual Studio includes this line in the AssemblyInfo.cs file which can be found under Properties in most projects.
To get around this error you can either:
Rename your property (recommended):
protected bool isNew;
Set your whole assembly to be non CLS compliant:
[assembly: CLSCompliant(false)]
Add an attribute just to your property:
[CLSCompliant(false)]
protected bool _isNew;
Change the scope of the property, so that it can not be seen outside the assembly.
private bool _isNew;