2

I Have WCF Service Contract and Using a class interface as a parameter as follow :

[ServiceContract(Name = "IFrameworkBaseService", CallbackContract = typeof(IFrameworkBaseServiceCallback))]
public interface IFrameworkBaseService
{
    [OperationContract]
    void InitializeConnection(IClientID clientID);
}

but I get the following error :

The communication object, System.ServiceModel.Channels.ServiceChannel, cannot be used for communication because it is in the Faulted state

Can anyone help me by this problem

Thanks Afshin

Tim
  • 28,212
  • 8
  • 63
  • 76
Afshin
  • 23
  • 2
  • When does the error occur? Can you post the code where the error occurs? This has nothing to do with the interface - something went wrong and the channel is faulted. It can't be used any further - you'll have to abort the channel and open a new one. – Tim Aug 27 '11 at 07:23

1 Answers1

0

I think the concret object you passed in for the IClientID is just unknown to the service. You have to add it with KnownType-Attribute

[ServiceContract(Name = "IFrameworkBaseService", CallbackContract = typeof(IFrameworkBaseServiceCallback))]
[KnownType(typeof(MyClientId))]
public interface IFrameworkBaseService
{
    [OperationContract]
    void InitializeConnection(IClientID clientID);
}
Random Dev
  • 51,810
  • 9
  • 92
  • 119
  • Shouldn't that be `[KnownType(typeof(IClientID))]`? – Tim Aug 27 '11 at 07:26
  • no - you have to add *all* the concrete types you want to add – Random Dev Aug 27 '11 at 07:32
  • 6
    The idea is good but doesn't work like this: KnownTypeAttribute cannot be applied on an interface... You can use **ServiceKnownTypeAttribute** on the ServiceContract instead – Charles HETIER Aug 05 '13 at 09:48
  • 2
    TBH - this is two years old and I do not know if I check (compiled) this - but you might be right - indeed - make it a answer or change mine to help the community - maybe the question can be closed this way. – Random Dev Aug 05 '13 at 13:43