Not CLS-compliant

G

Guest

I have an argument in the constructor for a VB form that as a parameter that
looks like:

ByVal lblHeader As Controls.MGLabel

Visual Studio 2005 gives me a warning:

Type of parameter 'lblHeader' is not CLS-compliant

I am not sure what to do.

Thank you.

Kevin
 
G

Guest

I wouldn't worry about it. This warning is telling you that, if you use this
type, your code will not be CLS compliant. CLS being the Common Language
Specification, which dictates what language features must be supported in
every .NET language. Not being CLS compliant means that, if you release your
code as a reusable library, a consumer writing in a different .NET language
(like C#, or IronPython, or even Cobol.NET) may have problems using your DLL.
If you don't care about this, then the warning can safely be ignored. You
can mark your assembly with an attribute to turn off the error. Do a search
for CLSCompliantAttribute for more info.
 
G

Guest

From the information that I have given can you tell what is "non-compliant"
about the parameter?
 
G

Guest

Well, the problem is that I have no idea what a MGLabel is. If you created
that class yourself, it may contain a public variable or parameter or a
public method that has a parameter or return type that is non-CLS compliant.
Or, the type itself (if you bought the control from a company) may be marked
with the attribute CLSCompliant(false). Hard to say. If you can post the
code for the control here, I could take a look at it. Or, if someone else
designed the control and it's a .NET control, you can use Lutz Roeder's
Reflector to view the code for the control and see what's going on in there.

The main thing to take away from this is that CLS compliance doesn't really
matter unless you are exposing a type that is not CLS compliant in a reusable
code library that you are selling or giving to other .NET developers. If you
are using it internally, just mark the assembly that contains the
non-compliant code with the attribute CLSCompliant(false) and you'll never
have to see that message again.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top