Reputation: 12803
Does anyone know if it is possible to serialize and pass an enum through WCF with its associated attributes?
For example:
public enum Dog
{
[Description("German Shepard")]
GERMAN_SHEPARD = 1,
[Description("Labrador Retriever")]
LABRADOR_RETRIEVER = 2
}
I then want to pass an instance of this enum as the return value of a method exposed via WCF. When the calling code uses "Add Service Reference" it should be able to reconstruct the Description attribute.
Thanks for any help.
Upvotes: 1
Views: 516
Reputation: 12680
You may need to mark the enum with the DataContract and EnumMember attributes so the WSDL with contain appropriate values.
Upvotes: 0
Reputation: 15579
You should set up your enum(s) and other types to be transported into a shared assembly. Then, instead of using the "Add Service Reference", you can use the /r
flag along with svcutil
to generate your service proxy.
Your client application should then reference the enum from the shared assembly instead.
Upvotes: 1