【发布时间】:2015-05-07 15:23:33
【问题描述】:
事实上我已经找到了解决问题的方法,但我只是好奇。
我遇到了以下错误消息 " 此代理不支持 UnlockObject 方法。如果方法未使用 OperationContractAttribute 标记或接口类型未使用 ServiceContractAttribute 标记,则可能发生这种情况"
这是我的界面:
[ServiceContract(CallbackContract = typeof(IServeurCallback), SessionMode.Required)]
public interface IServeur
{
[OperationContract(IsOneWay = true)]
void UnlockObject<T>(Guid ClientId, ObjectId toUnlock, string collectionName);
[...]
}
它是如何在我的服务器中实现的
[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall, ConcurrencyMode = ConcurrencyMode.Multiple)]
public class Serveur : Proxy.IServeur
{
public void UnlockObject<T>(Guid ClientId, ObjectId toUnlock, string collectionName)
{
/*stuff using <T>*/
}
}
以及如何从我的客户那里调用它
if (this.comboBox1.SelectedItem.ToString() == "Projet")
this.channel.UnlockObject<ProjectClass.Project>(client._Guid, toSend, "collection_Project");
else if (this.comboBox1.SelectedItem.ToString() == "Object")
this.channel.UnlockObject<Object.c_Object>(client._Guid, toSend, "collection_Object");
else if (this.comboBox1.SelectedItem.ToString() == "ObjString")
this.channel.UnlockObject<ObjString.ObjString>(client._Guid, toSend, "collection_ObjString");
(this.channel 是这样创建的
DuplexChannelFactory<Proxy.IServeur> factory;
/* do stuff to make it usable */
Proxy.IServeur channel = factory.CreateChannel();
我通过删除
解决了这个问题<T>
来自所有功能。现在我的代码有点脏,但运行良好
为什么会出现这个错误信息?
【问题讨论】:
-
如果您发布解决方案,我们或许可以告诉您为什么会发生这种情况。否则就是猜谜游戏。