johnatmears
Posts: 3
Joined: Thu May 29, 2008 11:33 am
Location: United Kingdom

ComPort is not CLS-compliant

Thu May 29, 2008 11:46 am

I have just started using Serial Tools standard edition for a Compact Framework VB.Net project in VS 2005. I'm using SerialNET.200.CF.dll. It is working fine but I have a property defined as

Public WriteOnly Property ComPort() As SerialNET.Port

Set(ByVal value As SerialNET.Port)
mobjComPort = value
End Set

End Property

and get the warning "Return type of function 'ComPort' is not CLS-compliant"

I searched the forums for a similar problem and found somebody with the same message using GPS Tools. The suggestion was that the wrong DLL was being used.

Am I using the correct Serial Tools DLL and if I am, how can I suppress this message.

Thankyou for what looks like an excellent library.

John.

User avatar
johan
GpsGate
Posts: 14981
Joined: Wed Aug 04, 2004 10:40 pm
Location: Sweden
Contact: Website

RE: ComPort is not CLS-compliant

Thu May 29, 2008 12:20 pm

This is not really a SerialTools question. It is more a "How to program VB.NET".

You cannot set an object "By Value".

Regards,
Johan

Franson Support

johnatmears
Posts: 3
Joined: Thu May 29, 2008 11:33 am
Location: United Kingdom

RE: ComPort is not CLS-compliant

Thu May 29, 2008 1:35 pm

Thank you for the reply, especially as you thought it is not a SerialTools problem.

My example property is a very standard way of assigning an object from one object to another. Everyone does this ALL the time. For example, I could have a property defined as a Bitmap and assign another bitmap to that property. Obviously Bitmap is a class. I'm no expert on this but I'd say the SerialNET.Port class is not marked as being CLS compliant and hence anyone exposing it as a public property will get this warning.

Regards,

John.

johnatmears
Posts: 3
Joined: Thu May 29, 2008 11:33 am
Location: United Kingdom

RE: ComPort is not CLS-compliant

Thu May 29, 2008 1:52 pm

In fact as I have the source code I just changed

namespace SerialNET

to

[assembly: CLSCompliant(true)]
namespace SerialNET

recompiled and the warning has gone away.

John.

Return to “SerialTools”