user38230
user38230

Reputation: 665

expose enum in WCF to be consumed by Client. WCF/C#/VS-2008

This is my starting point link text to expose an enum which the Client can consume; it is not part of method signature. My code compiles but I am unable to view it in wsdl and unable to use it in my C# windows form application test project. Is the test code in the link missing something?

Upvotes: 0

Views: 1219

Answers (2)

user38230
user38230

Reputation: 665

The link, link text,that I was following gave this code

[ServiceKnownType("GetKnownTypes", typeof(EnumHelper))]

If I changed it to this

[ServiceKnownType("GetKnownTypes", typeof(MyEnumName))]

My consuming client is able to view the enum type. The ? is why doesnt the helper static class assist in exposing the enum. I even came across this link text

Upvotes: 0

Andrew Hare
Andrew Hare

Reputation: 351536

Use the KnownType attribute on an existing data contract.

[KnownType(typeof(YourEnum))]
[DataContract]
public class FooContract { }

Upvotes: 2

Related Questions