views:

303

answers:

2

I'm using the Cook Computing XMLRPC framework in C#. I'm calling a remote function that expects an int. I want to use an enumeration in the client code instead of just calling the function with the digits hard-coded in the function parameters.

The code compiles successfully, but during testing an XmlRpcUnsupportedTypeException is throw. The message states that my enumeration cannot be mapped to an XML-RPC type. The enum is as follows:

public enum Codes : int
{
    Installed = 903,
}

I have a feeling there is something simple I am overlooking, but can't put my finger on it so I'm here shining my Bat signal into the clouds!

+2  A: 

tried explicit casting? (int)Installed

MSDN:

The underlying type specifies how much storage is allocated for each enumerator. However, an explicit cast is necessary to convert from enum type to an integral type. For example, the following statement assigns the enumerator Sun to a variable of the type int by using a cast to convert from enum to int:

int x = (int)Days.Sun;

PoweRoy
+2  A: 

You have to explicitly cast it to an int:

int code = Codes.Installed; // doesn't work.
int code = (int) Codes.Installed; // works.
Michael Meadows