Home All Groups Group Topic Archive Search About
Author
15 Jan 2007 12:42 AM
John
Hi

After importing my vs 2003 project into vs 2005 I am getting the error Name
'_DateColumn' is not CLS-compliant. on the second line of below code;

<System.Diagnostics.DebuggerNonUserCodeAttribute()> _
Public ReadOnly Property _DateColumn() As System.Data.DataColumn
Get
        Return Me.column_Date
End Get
End Property

What does that mean and how can I fix it? I suspect this code was generated
by vs 2003 itself.

Regards

Author
15 Jan 2007 3:01 AM
Michael C
Show quote Hide quote
"John" <John@nospam.infovis.co.uk> wrote in message
news:OJXMZ4DOHHA.5064@TK2MSFTNGP04.phx.gbl...
> Hi
>
> After importing my vs 2003 project into vs 2005 I am getting the error
> Name '_DateColumn' is not CLS-compliant. on the second line of below code;
>
> <System.Diagnostics.DebuggerNonUserCodeAttribute()> _
> Public ReadOnly Property _DateColumn() As System.Data.DataColumn
> Get
>        Return Me.column_Date
> End Get
> End Property
>
> What does that mean and how can I fix it? I suspect this code was
> generated by vs 2003 itself.

I suspect it's the underscore.

Michael
Author
15 Jan 2007 4:58 PM
Fabio Z
"John" <John@nospam.infovis.co.uk> ha scritto nel messaggio

> <System.Diagnostics.DebuggerNonUserCodeAttribute()> _
> Public ReadOnly Property _DateColumn() As System.Data.DataColumn
> Get
>        Return Me.column_Date
> End Get
> End Property
>
> What does that mean and how can I fix it? I suspect this code was
> generated by vs 2003 itself.

not CLS Compliant means that the *public* declaration doesn't follows the
CLR specifications.
This means that another .Net language may not understand correctly that
declaration if it uses your assembly as a reference.

In this case I think that the use of "_" as a name of a public member is a
bad practise.

Author
16 Jan 2007 3:45 AM
_AnonCoward
Show quote Hide quote
"John" <John@nospam.infovis.co.uk> wrote in message
news:OJXMZ4DOHHA.5064@TK2MSFTNGP04.phx.gbl...
:
: Hi
:
: After importing my vs 2003 project into vs 2005 I am getting the
: error Name '_DateColumn' is not CLS-compliant. on the second line
: of below code;
:
: <System.Diagnostics.DebuggerNonUserCodeAttribute()> _
: Public ReadOnly Property _DateColumn() As System.Data.DataColumn
: Get
:        Return Me.column_Date
: End Get
: End Property
:
: What does that mean and how can I fix it? I suspect this code was
: generated by vs 2003 itself.
:
: Regards


It's the underscore.

http://msdn2.microsoft.com/en-us/library/k5645wwb.aspx

It's due the the fact that there are C/C++ compilers for .Net. In
these languages, names with leading underscore characters are reserved
for the "implementation" under certain specific rules (I've seen "the
implementation" defined as anything other than the code the programmer
is writing, btw). It states in the SDK documentation regarding
variable names in the C++ language:


    Use of two sequential underscore characters ( __ ) at the
    beginning of an identifier, or a single leading underscore
    followed by a capital letter, is reserved for C++ implementations
    in all scopes. You should avoid using one leading underscore
    followed by a lowercase letter for names with file scope because
    of possible conflicts with current or future reserved identifiers.


Since VB is not case sensitive, "_DateColumn" and "_dateColumn" are
identical. However, in C/C++/C# they are not. The first version of the
name is not legal in C++ but the second version is (although
discouraged). Since VB doesn't differentiate by case, neither version
is considered CLS compliant.


Ralf
--
--
----------------------------------------------------------
*             ^~^                   ^~^                  *
*          _ {~ ~}                 {~ ~} _               *
*         /_``>*<                   >*<''_\              *
*        (\--_)++)                 (++(_--/)             *
----------------------------------------------------------
There are no advanced students in Aikido - there are only
competent beginners. There are no advanced techniques -
only the correct application of basic principles.