none
Typed DataSet not CLS-compliant? RRS feed

  • Question

  • Our application has about 20 forms and DataSets (one per form). All of the DataSets have been generated through the Visual Studio Designer and none of them have any additional code (i.e. partial classes). I added [assembly: CLSCompliant(true)] attribute to the AssemblyInfo.cs file to ensure that we write CLS-compliant code.

    When I compile the project, I get a warning that "Type of 'MyForm.myDataSet' is not CLS-compliant". This warning occurs on the class that uses an instance of the DataSet, not on the DataSet itself.

    Any idea why this is happening?

    Thursday, July 12, 2007 11:35 AM

All replies

  • This might be a shot in the dark - however, do remember reading that certain datatypes when used in the STD can be flagged as non-compliant, e.g. DateTime.  Whether there's a workaround to this - or whether you need to cast to another data type is a different question...
    Thursday, July 12, 2007 12:54 PM
  • A class as a whole is not CLS compliant if any of its members (or its base class) is not CLS compliant.  This is usually caused by using a non-CLS type like unsigned integers.  If you have any properties/methods that require any of these types then your class is not CLS compliant.  However you can apply the CLSCompliant(false) attribute to each non-compliant member to produce an otherwise CLS compliant class.  The general rule however is that you should provide a CLS-compliant equivalent for each non-compliant member.  A typed dataset itself is CLS compliant so it must be one of the members that is causing your problem.

     

    CLS compliance is really only important for reusable libraries.  Applications do not benefit from CLS compliant as they are not reused (in most cases).  Therefore I would not worry about making the forms or UI of your application CLS compliant unless the UI is part of a larger UI library that you intend to reuse.

     

    Michael Taylor - 7/12/07

    http://p3net.mvps.org

     

     

     

    Thursday, July 12, 2007 1:08 PM