Reputation: 894
As a matter of fact I already found a solution to my problem, But I am just curious.
I came across the following error message " The method UnlockObject is not supported on this proxy. It can happen if the method is not marked with OperationContractAttribute or if the interface type is not marked with ServiceContractAttribute"
here is my interface :
[ServiceContract(CallbackContract = typeof(IServeurCallback), SessionMode.Required)]
public interface IServeur
{
[OperationContract(IsOneWay = true)]
void UnlockObject<T>(Guid ClientId, ObjectId toUnlock, string collectionName);
[...]
}
How it is implemented in my server
[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>*/
}
}
and how it is called from my client
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 was created this way
DuplexChannelFactory<Proxy.IServeur> factory;
/* do stuff to make it usable */
Proxy.IServeur channel = factory.CreateChannel();
I solved this by removing the
<T>
from all the function. Now my code is a little bit dirtier, but it is working fine
Why does this error message show up ?
Upvotes: 1
Views: 7626
Reputation: 2468
You have exception because wsdl
does not support open generic types and so WCF
service cannot expose them on operation contracts as it uses wsdl
to expose metadata of your operations.
It is possible to expose bounded generics in your code (see details) or since the <T>
argument only identifies the type you can add it as another argument
[OperationContract(IsOneWay = true)]
void UnlockObject(Type objectType,Guid ClientId, ObjectId toUnlock, string collectionName);
Upvotes: 2