Setting CLS compliance for a .NET assembly
Asked Answered
S

2

31

Setting CLS compliance for an entire .NET assembly is possible. But how is it actually done? E.g. with Visual Studio 2008?

Sancho answered 21/4, 2009 at 20:7 Comment(0)
F
42

Visual Studio adds a directive for the compiler, and the compiler checks the code for some more strict rules than in the native programming language.

You can add the CLS compliant attribute to all your project by adding the assembly level attribute

[assembly: CLSCompliant(true)]

anywhere in your project, generally in the assemblyinfo.cs file.

If the line using System; is not at the top of the file, add it. Or, use the long form:

[assembly: System.CLSCompliant(true)]
Filigree answered 21/4, 2009 at 20:17 Comment(0)
B
21

You need to add this line to one of your source files:

[assembly: System.CLSCompliant(true)]

More info on CLS compliant code here.

Normally you put this in assemblyinfo.cs

Booklover answered 21/4, 2009 at 20:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.