I can work with many WCF bindings, except netMsmqBinding
. All I get is:
CommunicationObjectFaultedException: "The communication object, System.ServiceModel.ServiceHost, cannot be used for communication because it is in the Faulted state."
at System.ServiceModel.Channels.CommunicationObject.Close(TimeSpan timeout)
I tried it in a Windows Server 2008 R2 with the following features installed
- Message Queueing
- Message Queueing Services
- Message Queueing Server
- Message Queueing Triggers
- HTTP Support
- Multicasting Support
- Message Queueing DCOM Proxy
I tried also to add manually a private Message Queue in the Server Manager but it didn't work.
I am using a Windows Service to host my MSMQ. My Service Contract is
namespace MyCompany.Services
{
[ServiceContract(Name = "ServiceName",
Namespace = "http://MyCompany/ServiceName")]
public interface IServiceName
{
[OperationContract(IsOneWay = true)]
void Insert(MyData[] data);
}
[DataContract]
public class MyData
{
[DataMember]
public DateTime DateTime { get; set; }
[DataMember]
public double Lat { get; set; }
[DataMember]
public double Lon { get; set; }
[DataMember]
public TimeSpan Timespan { get; set; }
[DataMember]
public Guid Id { get; set; }
[DataMember(IsRequired = false)]
public int? Category { get; set; }
}
}
And my app.config contains
<endpoint
address="net.msmq://localhost/private/ServiceName"
binding="netMsmqBinding"
contract="MyCompany.Services.IServiceName"
bindingConfiguration="tolerant"
behaviorConfiguration="tolerant"
/>
and
<netMsmqBinding>
<binding name="tolerant"
maxReceivedMessageSize="2147483647"
>
<readerQuotas maxArrayLength="2147483647" />
<security mode="None"/>
</binding>
</netMsmqBinding>