Click here to Skip to main content
13,140,231 members (49,964 online)
Rate this:
 
Please Sign up or sign in to vote.
See more:
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>
          &lt;baseAddresses&gt;
            <add baseaddress="http://localhost:8000/msmqservice" />
          &lt;/baseAddresses&gt;
        </host>
        <endpoint address="net.msmq://localhost/private/requestqueue">
                  binding="netMsmqBinding"
                  contract="MSMQService.IService1"
                  bindingConfiguration="myBinding"&gt;
          <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 ?
Posted 19-May-15 4:54am
Updated 19-May-15 4:58am
v4
Comments
virusstorm 19-May-15 14:22pm
   
Did you add an entry in your client configuration file (app.config) for the WCF service? If so, what does your client configuration file look like?
Member 8757025 25-May-15 5:08am
   
I am yet to host the service. Whenever i am trying to host the service through service host, getting this error. my host is a simple windows app. app.config file is whatever generated automatically when i added my service reference. I have not made any changes in it. But, still not able to make it work. Pls let me know if you need any more information on this.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy |
Web03 | 2.8.170915.1 | Last Updated 19 May 2015
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100