【发布时间】:2016-02-05 11:10:06
【问题描述】:
我无法从 WCF 客户端传递多个 enum 值。
class Client
{
static void Main(string[] args)
{
ChannelFactory<IWCFService> channelFactor = new ChannelFactory<IWCFService>("HellowWorldServiceEndpoint");
channelFactor.Open();
IWCFService proxy = channelFactor.CreateChannel();
Console.WriteLine(proxy.GetEnumString(EnumComponents.enumVal1)); // -> SUCCEDED HERE (only one Enum value)
// Console.WriteLine(proxy.GetEnumString(EnumComponents.enumVal1| EnumComponents.enumVal2)); // -> **** FAILS HERE with invalid enum type. *****
Console.Read();
}
}
例外是, 尝试序列化参数http://tempuri.org/:components 时出错。 InnerException 消息是“枚举值 'enumVal1, enumVal2”对于类型“Microsoft.Geospatial.Data.Gateway.ObjectModel.EnumComponents”无效并且无法序列化。如果类型具有 DataContractAttribute 属性,请确保存在必要的枚举值并使用 EnumMemberAttribute 属性进行标记。'。请参阅 InnerException 了解更多详情
仅供参考,枚举来自一个公共库,该库作为参考添加到 WCFclient、WCFserver 和 WCFinterface 中。
如果是正常的函数调用,同样的炒锅。有没有办法解决这个问题?
【问题讨论】:
-
请参阅"Should questions include “tags” in their titles?",其中的共识是“不,他们不应该”!