473,320 Members | 2,161 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,320 software developers and data experts.

CLS compliance problem



I have the following property in one of my applications but when I do a build I get a warning saying that it is not CLS compliant.
Swatch is a class defined in a separate project/dll. I get the same problem on properties that use Enums defined in the same dll as
the swatch.

Is the problem that the return values are declared in a different dll? Or, is the problem something else.

Originally I had the properties set as methods but FX Cop insisted that I should make Properties out of them. Can I only make CLS
compliant properties out of basic values such as int and bool.

Thanks,
Steve


public Swatch DartColor
{
get
{
return (this.scbxDartColor.SelectedSwatch);
}
set
{
if (value != null && value is Swatch)
{
this.scbxDartHeadArcColor.SetSelectedSwatch(value. TypeOfSwatch, value.Description);

meTkd.DartColor = DartColor;
if (meRedraw)
Redraw(meDrawControl);
}
}

}
Note: scbxDartColor is a swatch combo box. Just a combo box with a list of available swatch colors.
Jul 21 '08 #1
3 1060
steve wrote:
I have the following property in one of my applications but when I do a build I get a warning saying that it is not CLS compliant.
Swatch is a class defined in a separate project/dll. I get the same problem on properties that use Enums defined in the same dll as
the swatch.
Add

[assembly: CLSCompliant(true)]

to the offending library's AssemblyInfo.cs, recompile, and fix any compiler
warnings that may result.

If you cannot change the original assembly, you can do two things: either
wrap all the types exposed in assembly #1 in internal types and do not
re-expose them (which is incredibly tedious) or throw in the towel and make
sure your own assembly is marked as not being CLS-compliant either. You can
do that, unsurprisingly, with

[assembly: CLSCompliant(false)]

CLS compliance is generally a good thing, and for a truly reusable library
it's almost essential, but you can live without it if necessary. On an
application assembly, it doesn't matter a whole lot, since you typically
won't be accessing types in it anyway, let alone from another CLR language.

--
J.
Jul 21 '08 #2
Steve,

I imagine that the issue is with the enum itself, not with the property.

Can you show the definition of the enumeration?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"steve" <s_******@yahoo.comwrote in message
news:r7********************************@4ax.com...
>

I have the following property in one of my applications but when I do a
build I get a warning saying that it is not CLS compliant.
Swatch is a class defined in a separate project/dll. I get the same
problem on properties that use Enums defined in the same dll as
the swatch.

Is the problem that the return values are declared in a different dll? Or,
is the problem something else.

Originally I had the properties set as methods but FX Cop insisted that I
should make Properties out of them. Can I only make CLS
compliant properties out of basic values such as int and bool.

Thanks,
Steve


public Swatch DartColor
{
get
{
return (this.scbxDartColor.SelectedSwatch);
}
set
{
if (value != null && value is Swatch)
{

this.scbxDartHeadArcColor.SetSelectedSwatch(value. TypeOfSwatch,
value.Description);

meTkd.DartColor = DartColor;
if (meRedraw)
Redraw(meDrawControl);
}
}

}
Note: scbxDartColor is a swatch combo box. Just a combo box with a list of
available swatch colors.

Jul 21 '08 #3

Sorry, I figured out what was missing.

I didn't mark the Swatch assembly as being CLS compliant
Steve

On Mon, 21 Jul 2008 12:53:41 -0400, steve <s_******@yahoo.comwrote:
>

I have the following property in one of my applications but when I do a build I get a warning saying that it is not CLS compliant.
Swatch is a class defined in a separate project/dll. I get the same problem on properties that use Enums defined in the same dll as
the swatch.

Is the problem that the return values are declared in a different dll? Or, is the problem something else.

Originally I had the properties set as methods but FX Cop insisted that I should make Properties out of them. Can I only make CLS
compliant properties out of basic values such as int and bool.

Thanks,
Steve


public Swatch DartColor
{
get
{
return (this.scbxDartColor.SelectedSwatch);
}
set
{
if (value != null && value is Swatch)
{
this.scbxDartHeadArcColor.SetSelectedSwatch(value. TypeOfSwatch, value.Description);

meTkd.DartColor = DartColor;
if (meRedraw)
Redraw(meDrawControl);
}
}

}
Note: scbxDartColor is a swatch combo box. Just a combo box with a list of available swatch colors.
Jul 21 '08 #4

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

Similar topics

119
by: rhat | last post by:
I heard that beta 2 now makes ASP.NET xhtml compliant. Can anyone shed some light on what this will change and it will break stuff as converting HTML to XHTML pages DO break things. see,...
100
by: Roose | last post by:
Just to make a tangential point here, in case anyone new to C doesn't understand what all these flame wars are about. Shorthand title: "My boss would fire me if I wrote 100% ANSI C code" We...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.