Serializing Enum type is non CLS-Compliant.

J

Jim Hart

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
 
J

Jim Hart

Ahh - never mind.

Needed to put a CLSCompliant property on the 'Util'
project. All is now well.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top