Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
'type' cannot be marked as CLS-Compliant because it is a member of non CLS-compliant type 'type'
This warning occurs if a nested class with the CLSCompliant attribute set to true is declared as a member of a class declared with the CLSCompliant attribute set to false. This is not allowed, since a nested class cannot be CLS-compliant if it is a member of an outer class that is not CLS-compliant. To resolve this warning, remove the CLSCompliant attribute from the nested class, or change it from true to false. For more information on CLS Compliance, see Writing CLS-Compliant Code and Common Language Specification.
Example
The following sample generates CS3018.
// CS3018.cs
// compile with: /target:library
using System;
[assembly: CLSCompliant(true)]
[CLSCompliant(false)]
public class Outer
{
[CLSCompliant(true)] // CS3018
public class Nested {}
// OK
public class Nested2 {}
[CLSCompliant(false)]
public class Nested3 {}
}