我有一个工作正常的WCF服务,今天我更改了合同中的一个函数的代码我添加了这两行:
var name = (from x in new ManagementObjectSearcher("SELECT * FROM Win32_OperatingSystem").Get().OfType<ManagementObject>()
select x.GetPropertyValue("Caption")).FirstOrDefault();
string osFriendlyName = name != null ? name.ToString() : "Unknown";
这意味着我在wcf服务器类中向System.Management添加了引用。 合同没有改变我返回我之前返回的相同对象... 现在当客户端尝试调用此函数时,我得到了这个异常:
The message with Action 'http://tempuri.org/IEnvironmentService/GetComputerDetails' cannot be
processed at the receiver, due to a ContractFilter mismatch at the EndpointDispatcher. This may be
because of either a contract mismatch (mismatched Actions between sender and receiver) or a
binding/security mismatch between the sender and the receiver. Check that sender and receiver have
the same contract and the same binding (including security requirements, e.g. Message, Transport,
None).
你觉得这个问题怎么样?即使合同没有变更,我是否需要更新客户的服务参考?
答案 0 :(得分:0)
我想您需要更新客户端中的服务引用,因为metadata服务可能已更改,并且可能会引发错误。
答案 1 :(得分:0)
好的,我的问题解决了我重建到解决方案,现在好了!