13

When I run StyleCop, I got this error message saying that I need to Mark the dll with CLSCompliant(true).

What is this? How can I set the Mark the dll with CLSCompliant(true)?

Error   4   CA1014 : Microsoft.Design : 
Mark 'SOMETHING.dll' with CLSCompliant(true) because it exposes externally 
                     visible types. ModelsimCommunicator
JaredPar
  • 673,544
  • 139
  • 1,186
  • 1,421
prosseek
  • 155,475
  • 189
  • 518
  • 818

1 Answers1

19

To mark the DLL as CLS compliant do the following in the root namespace.

[assembly: CLSCompliant(true)]

Note: This error is coming from FxCop not StyleCop. FxCop errors are prefixed with CA while StyleCop uses the SA prefix

JaredPar
  • 673,544
  • 139
  • 1,186
  • 1,421
  • 2
    Are you sure it's *in* the root namespace, because Microsoft says have it *before* the namespace. (http://msdn.microsoft.com/query/dev10.query?appId=Dev10IDEF1&l=EN-US&k=k(MARKASSEMBLIESWITHCLSCOMPLIANT)%3bk(TargetFrameworkMoniker-%22.NETFRAMEWORK%2cVERSION%3dV4.0%22)&rd=true) – Ian Boyd Aug 29 '11 at 12:07
  • 4
    try adding this to AssemblyInfo.cs – hnafar Jun 30 '15 at 17:41
  • The CA rules are also part of the Code Analysis run when you enable CA for a project. – Patrick Peters Oct 10 '16 at 09:38