locked
Invalid Enum Value RRS feed

  • Question

  •  

    Hi

     

    I have a basic enum structure as follows:

    Code Snippet

    [DataContract]

    public enum Action : int {

    [EnumMember] Add = 1,

    [EnumMember] Update,

    [EnumMember] Remove

    }

     

    The Action enum is used in my class called Card as follows:

    Code Snippet

    [DataContract]

    public class Card : ICard {

    private string m_number;

    private Action m_action = Action.Add;

     

    [DataMember]

    public string Number {

    get {

    return m_number;

    }

    set {

    m_number = value;

    }

    }

     

    [DataMember]

    public Action Action{

    get {

    return m_action;

    }

    set {

    m_action = value;

    }

    }

    }

     

    So that I can pass interfaces around, I'm using the NetDataContract on my service as follows:

    Code Snippet

    [ServiceContract]

    public interface IManagementService {

    [NetDataContract]

    [OperationContract(IsOneWay = true)]

    void ExecuteCard(string name, ICard card);

    }

     

     

     

    If I understand correctly I can't use the svcutil to generate a proxy and call the ExecuteCard method, because the utility converts ICard to object.  So I've been using Channels to call the method, however I end up with this exception and don't know how to get pass it:

     

    The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://mynamespace:card. The InnerException message was 'Invalid enum value 'Add' cannot be deserialized into type 'Components.Action'. Ensure that the necessary enum values are present and are marked with EnumMemberAttribute attribute if the type has DataContractAttribute attribute.'.  Please see InnerException for more details.

     

    Any ideas?
    Tuesday, July 8, 2008 6:51 AM

Answers