Marking Assemblies and Types as CLS-Compliant

Chapter 2, “Getting Started with the Visual Studio 2010 IDE,” and Chapter 3, “The Anatomy of a Visual Basic Project,” offer an overview of assemblies. When you produce a reusable component such as a class library or a user control, such as a .dll assembly, you need to ensure that it is CLS-compliant. You can add the following attribute to the assembly definition:

<Assembly: CLSCompliant(True)>

This attribute tells the compiler to check if a type used in your code is CLS-compliant. If the compiler finds a CLS-incompliant type, it throws a warning message. Assembly members should also be marked as CLS-compliant, if you plan that they will be. For example, a class is defined CLS-compliant as follows: ...

Get Visual Basic® 2010 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.