【发布时间】:2014-10-16 18:03:19
【问题描述】:
我有一个非常简单的 WCF 服务在共享点服务器上运行,它的 ServiceContract 看起来像这样:
[ServiceContract]
interface iSPTest
{
[OperationContract]
Stream Process(Stream input);
}
这很好用,我可以使用svcutil 来生成代理和配置文件。但是,我想将其更改为枚举:
[OperationContract]
Stream Process(Stream input, MyEnumType foo);
定义enum:
[DataContract]
public enum MyEnumType
{
[EnumMember]
Default = 0,
[EnumMember]
Foo,
[EnumMember]
Bar
};
但是,当我这样做时,我无法再让代理生成。我收到一个错误:
Metadata contains a reference that cannot be resolved: 'http://myserver/_vti_
bin/SPTest/SPTest.svc'.
The requested service, 'http://myserver/_vti_bin/SPTest/SPTest.svc' could not
be activated. See the server's diagnostic trace logs for more information.
看起来这应该是一件简单的事情。我尝试将ServiceKnownType 添加到ServiceContract,但这似乎没有帮助。为什么它似乎无法选择枚举类型?对于奖励积分,是否可以在服务器引用但客户端没有的程序集中使用现有枚举?因为在那种情况下,不可能用DataContract 标记enum?
【问题讨论】: