Home All Groups Group Topic Archive Search About
Author
28 Jun 2006 3:09 PM
Kevin Burton
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
Author
29 Jun 2006 3:38 PM
William Sullivan
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.

Show quoteHide quote
"Kevin Burton" wrote:

> 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
Are all your drivers up to date? click for free checkup

Author
30 Jun 2006 5:35 AM
Kevin Burton
From the information that I have given can you tell what is "non-compliant"
about the parameter?

Show quoteHide quote
"William Sullivan" wrote:

> 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.
>
> "Kevin Burton" wrote:
>
> > 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
Author
30 Jun 2006 1:43 PM
William Sullivan
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.

Show quoteHide quote
"Kevin Burton" wrote:

> From the information that I have given can you tell what is "non-compliant"
> about the parameter?
>
> "William Sullivan" wrote:
>
> > 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.
> >
> > "Kevin Burton" wrote:
> >
> > > 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

Bookmark and Share