473,386 Members | 1,815 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,386 software developers and data experts.

Serializing Enum type is non CLS-Compliant.

Hi all! Can anyone explain this one to me. . .

I have a 'Util' namespace with a 'Common' class that
contains consts & values I use throughout multiple
projects. One of the members of this 'Common' class is
an enum like so:

public class Common
{
....
public enum thingsAsEnums {CAR, BOAT, HOUSE}
}

I use this enum in a Serializable class / different
project as the type of a field, then create a property to
get/set it...

[Serializable]
public class DoThings
{
....
private Common.thingsAsEnums myThings;

public Common.thingsAsEnums MyThings
{
.... standard get/set here ....
}
}

When I compile, I get the "Type
of '...DoThings.thingsAsEnums' is not not CLS-Compliant."
error. This is for the property declaration (not the
actual field declaration).

If I move the 'thingsAsEnums' enum out of my Util
namespace/Common class and put it into my local
namespace, the error goes away.

Removing the CLSCompliant(true) property fixes the
problem, but I can't do that. Plus, it's cheating - I
want to find out what's going on here.

Does anybody have the *slightest* idea of what is going
on, 'cause for the moment I am absolutely clueless.

TIA!

-- Jim Hart
Nov 16 '05 #1
1 3228
Ahh - never mind.

Needed to put a CLSCompliant property on the 'Util'
project. All is now well.
-----Original Message-----
Hi all! Can anyone explain this one to me. . .

I have a 'Util' namespace with a 'Common' class that
contains consts & values I use throughout multiple
projects. One of the members of this 'Common' class is
an enum like so:

public class Common
{
....
public enum thingsAsEnums {CAR, BOAT, HOUSE}
}

I use this enum in a Serializable class / different
project as the type of a field, then create a property toget/set it...

[Serializable]
public class DoThings
{
....
private Common.thingsAsEnums myThings;

public Common.thingsAsEnums MyThings
{
.... standard get/set here ....
}
}

When I compile, I get the "Type
of '...DoThings.thingsAsEnums' is not not CLS- Compliant."error. This is for the property declaration (not the
actual field declaration).

If I move the 'thingsAsEnums' enum out of my Util
namespace/Common class and put it into my local
namespace, the error goes away.

Removing the CLSCompliant(true) property fixes the
problem, but I can't do that. Plus, it's cheating - I
want to find out what's going on here.

Does anybody have the *slightest* idea of what is going
on, 'cause for the moment I am absolutely clueless.

TIA!

-- Jim Hart
.

Nov 16 '05 #2

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

Similar topics

5
by: Simon Burton | last post by:
In today's experiment, I was wondering if I could make the comparison operators (<,<=,>=,>) work on classes (types) according to inheritance. The idea is, for example, classes lower in the class...
0
by: Gad Rosenthal | last post by:
Can you direct the serialization process to correctly convert enum values? Example: public enum DiscreteOverlapping { none = -1, Ok = 0, StillOk = 0, Bad = -99
10
by: copx | last post by:
I want to save a struct to disk.... as plain text. At the moment I do it with a function that just writes the data using fprintf. I mean like this: fprintf(fp, "%d %d", my_struct.a, my_struct.b)...
21
by: Andreas Huber | last post by:
Hi there Spending half an hour searching through the archive I haven't found a rationale for the following behavior. using System; // note the missing Flags attribute enum Color {
0
by: Kenneth Baltrinic | last post by:
Is the following code correct for serializing a quasi-single class, that is a class that has a descreet (though more than one, so not a true singleton) number of static instances and no dynamically...
12
by: Michael Maes | last post by:
Hello, I have a BaseClass and many Classes which all inherit (directly) from the BaseClass. One of the functions in the BaseClass is to (de)serialize the (inherited) Class to/from disk. ...
1
by: Brien King | last post by:
I am binding to a collection of Business Objects in a GridView (Windows App, ..NET 2.0). In my Business Object I have a Property that is an ENUM. I want a Drop down box in the Grid that is...
47
by: Max | last post by:
Due to the behaviour of a particular COM object, I need to ensure that a request for a particular ASP page is finalized before another request for the page is processed. Does IIS have a way to...
34
by: Steven Nagy | last post by:
So I was needing some extra power from my enums and implemented the typesafe enum pattern. And it got me to thinking... why should I EVER use standard enums? There's now a nice little code...
10
by: yu_kuo | last post by:
I got series warning when using write enum type to a ostream using operator<<, like in call to `std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(int) '...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...

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.