473,405 Members | 2,404 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

CLS compliance and custom types


I have created a class with get/set methods but VS complains that the type of the variable is not CLS compliant. For example in the
following code :

namespace TilerSpace
{
public partial class TilerGoldenTriangleDEPanel : Form
{

public SwatchType PlusFilter
{
get
{
return scbxPlusDEColor.SwatchTypeList;
}
set
{
scbxPlusDEColor.SwatchTypeList = value;
}

} /* End of property PlusFilter */
}

I get a compiler warning "Type of PlusFilter is not CLS compliant".

SwatchType is a type declared in a seperate dll but included as a reference in the solution. Originally the dll was part of the
solution, though a separate project, and I didn't get this problem. Now having moved the code off to it's own dll I don't seem to be
able to get rid of the problem. Except, possibly, making it part of the solution again.

I could disable CLS compliance but I don't really want to do that. The application would always need to include the dll. Why should
this be a problem? I could include SwatchType variables in any other part of the code w/o getting a warning. Is there something
special about get/set or am I looking at this wrong way.
Thanks,

Steve
Aug 13 '07 #1
5 1815
"steve bull" <bu****@comcast.netwrote in message
news:rg********************************@4ax.com...
SwatchType is a type declared in a seperate dll
Can you include the declaration for swatchtype?
Aug 13 '07 #2

SwatchType is an enum but I don't think that is important. If I were to change it to bool or int the compiler would be happy. I have
various get/set properties. All the ones defined external to the project, be it an enum or a class type, are flagged as not being
CLS compliant.


On Mon, 13 Aug 2007 11:29:09 +1000, "Michael C" <no****@nospam.comwrote:
>"steve bull" <bu****@comcast.netwrote in message
news:rg********************************@4ax.com.. .
>SwatchType is a type declared in a seperate dll

Can you include the declaration for swatchtype?
Aug 13 '07 #3
steve bull wrote:
SwatchType is an enum but I don't think that is important. If I were to change it to bool or int the compiler would be happy. I have
various get/set properties. All the ones defined external to the project, be it an enum or a class type, are flagged as not being
CLS compliant.


On Mon, 13 Aug 2007 11:29:09 +1000, "Michael C" <no****@nospam.comwrote:
>"steve bull" <bu****@comcast.netwrote in message
news:rg********************************@4ax.com.. .
>>SwatchType is a type declared in a seperate dll
Can you include the declaration for swatchtype?
Well what is the underlying type of the enum. If it is unsigned then
you'll get the not CLS compliant message.

--
-glenn-
Aug 13 '07 #4
steve bull wrote:
I have created a class with get/set methods but VS complains that the type of the variable is not CLS compliant. For example in the
following code :

namespace TilerSpace
{
public partial class TilerGoldenTriangleDEPanel : Form
{

public SwatchType PlusFilter
{
get
{
return scbxPlusDEColor.SwatchTypeList;
}
set
{
scbxPlusDEColor.SwatchTypeList = value;
}

} /* End of property PlusFilter */
}

I get a compiler warning "Type of PlusFilter is not CLS compliant".

SwatchType is a type declared in a seperate dll but included as a reference in the solution. Originally the dll was part of the
solution, though a separate project, and I didn't get this problem. Now having moved the code off to it's own dll I don't seem to be
able to get rid of the problem. Except, possibly, making it part of the solution again.

I could disable CLS compliance but I don't really want to do that. The application would always need to include the dll. Why should
this be a problem? I could include SwatchType variables in any other part of the code w/o getting a warning. Is there something
special about get/set or am I looking at this wrong way.
Thanks,

Steve
Two guesses.

1. SwatchType is unsigned.
2. The project that uses this type does not have [CLSCompliant(true)] at
the assembly level.

So would need to know the type of SwatchType and if CLSCompliant is in
all of the mentioned projects or not.

--
-glenn-
Aug 13 '07 #5


Thanks, I had my main application set as CLS compliant but not the library that it called. Once I marked the librar as cls compliant
in AssemblyInfo the problem disappeared.

SwatchTYpe was declared as :
[Flags]
public enum SwatchType
{
None = 0x0000,
DoNotDraw = 0x0001,
SystemColor = 0x0002,
CustomColor = 0x0004,
ColorRange = 0x0008,
HueRange = 0x0010,
Shade = 0x0020,
HatchBrush = 0x0040,
Gradient = 0x0080,
All = 0x00FF,
EdgeColor = 0x003F

} /* End of enum SwatchTypes */
Thanks again,

Steve


On Mon, 13 Aug 2007 07:25:34 -0400, GlennDoten <gd****@gmail.comwrote:
>steve bull wrote:
>I have created a class with get/set methods but VS complains that the type of the variable is not CLS compliant. For example in the
following code :

namespace TilerSpace
{
public partial class TilerGoldenTriangleDEPanel : Form
{

public SwatchType PlusFilter
{
get
{
return scbxPlusDEColor.SwatchTypeList;
}
set
{
scbxPlusDEColor.SwatchTypeList = value;
}

} /* End of property PlusFilter */
}

I get a compiler warning "Type of PlusFilter is not CLS compliant".

SwatchType is a type declared in a seperate dll but included as a reference in the solution. Originally the dll was part of the
solution, though a separate project, and I didn't get this problem. Now having moved the code off to it's own dll I don't seem to be
able to get rid of the problem. Except, possibly, making it part of the solution again.

I could disable CLS compliance but I don't really want to do that. The application would always need to include the dll. Why should
this be a problem? I could include SwatchType variables in any other part of the code w/o getting a warning. Is there something
special about get/set or am I looking at this wrong way.
Thanks,

Steve

Two guesses.

1. SwatchType is unsigned.
2. The project that uses this type does not have [CLSCompliant(true)] at
the assembly level.

So would need to know the type of SwatchType and if CLSCompliant is in
all of the mentioned projects or not.
Aug 14 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Franz | last post by:
Greetings, I have created the following types: typedef struct _tbl_certificate{ int cert_id; char *cert_name; }tbl_certificate; typedef struct _cameraObj{ tbl_camera camera;
20
by: Nikolay Petrov | last post by:
Which is the best and convenient way to send/retrun custom types to/from Web Service? Serialization? The web service is not to be public accessible, it's a part of n-tier application. TIA
4
by: CrispinH | last post by:
I'm building an application generator and within it a user can create a new property (for the class they are building). I'd like then to offer a list of Types - built-in and custom - for this new...
1
by: Kris | last post by:
I read a column on sharing types between web services at http://msdn.microsoft.com/library/en-us/dnservice/html/service07162002.asp Sharing types can be acheived, similar to what described here...
2
by: gbanister | last post by:
I'd like to repost a message that I found in this group almost one year ago, because it's the exact problem I'm in and there was no solution offered to this post last year. (note: I was not the...
4
by: =?Utf-8?B?cmtvemxpbg==?= | last post by:
Is it possible to remotely host custom types? Some background... We have an application that uses custom user controls as 'templates' for entering certain kinds of data. The application is...
4
by: =?Utf-8?B?a2lzaG9y?= | last post by:
Hi, has any one used webservices for returning custom objects other than datasets like custom classes and their internal classes ?. What problems you have faced if any ? is there any limitation...
0
by: akshaychand | last post by:
Hi, I am designing a Schema Editor using the Schema Object Model in .NET 2.0. I am currently facing an problem wherein I want to list all the built-in data types as well as the custom types that...
1
by: poldoga | last post by:
Good day sirs, I am currently working on creating windows GUI software for a hardware device. The hardware's functions are stored in a DLL. Here is the structure for a function I need to import ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.