Hi All,
I have a sample wcf msmq service as shown below.
[ServiceContract]
public interface IService1
{
[OperationContract(IsOneWay = true)]
void SendCreditLimitRequest(string id);
}
public class Service1 : IService1
{
public void SendCreditLimitRequest(string id)
{
double value;
if (id == "1")
value = 10;
else if (id == "2")
value = 20;
else
value = 0;
}
}
<services>
<service name="MSMQService.Service1">
<host>
<baseAddresses>
<add baseaddress="http://localhost:8000/msmqservice" />
</baseAddresses>
</host>
<endpoint address="net.msmq://localhost/private/requestqueue">
binding="netMsmqBinding"
contract="MSMQService.IService1"
bindingConfiguration="myBinding">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
Now, if i run this service through wcftestclient it works fine. I am trying to host this service in one windows form.
ServiceHost myServiceHost = null;
private void button1_Click(object sender, EventArgs e)
{
myServiceHost = new ServiceHost(typeof(ServiceReference1.Service1Client));
myServiceHost.Open();
MessageBox.Show("Service Started!");
}
private void button2_Click(object sender, EventArgs e)
{
if (myServiceHost.State != CommunicationState.Closed)
{
myServiceHost.Close();
MessageBox.Show("Service Stopped!");
}
}
However, i am getting below error.
Service 'ClientForService.ServiceReference1.Service1Client' has zero application (non-infrastructure) endpoints. This might be because no configuration file was found for your application, or because no service element matching the service name could be found in the configuration file, or because no endpoints were defined in the service element.
I have seen n number of forums. Everywhere it is mentioned, we need to service name correct i.e. namespace and implemented class name. I have checked that also. But, still not able to make it work. I would really appreciate it if someone can help me in this ?