How to get information about the servicehost? (win 7 pro VS 2012 pro -- .net 4.5) RRS feed

  • Question

  • I create a simple CalculatorService from an MSDN tutorial.  I also was able to create a test host from the tutorial.  The sample project runs fine up to this point.  Then the tutorial says to use svcutil.exe.  Here is where I have the problem.  When I go to the command prompt and enter the code from the tutorial I get this error message:

    No connection could be made because the target machine actively refused it

    When I run the host application (console application) the service runs fine.  Here is the code from the host application

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.ServiceModel;
    using GettingStartedLib;
    using System.ServiceModel.Description;
    namespace GettingStartedHost
        class Program
            static void Main(string[] args)
                // Step 1 Create a URI to serve as the base address.
                Uri baseAddress = new Uri("http://localhost:8000/GettingStarted/");
                // Step 2 Create a ServiceHost instance
                ServiceHost selfHost = new ServiceHost(typeof(CalculatorService), baseAddress);
                    // Step 3 Add a service endpoint.
                    selfHost.AddServiceEndpoint(typeof(ICalculator), new WSHttpBinding(), "CalculatorService");
                    // Step 4 Enable metadata exchange.
                    ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
                    smb.HttpGetEnabled = true;
                    // Step 5 Start the service.
                    Console.WriteLine("The service is ready.");
                    Console.WriteLine("Press <ENTER> to terminate service.");
                    // Close the ServiceHostBase to shutdown the service.
                catch (CommunicationException ce)
                    Console.WriteLine("An exception occurred: {0}", ce.Message);

    How can I get information from ServiceHost selfhost?  How do I correctly use svcutil.exe with this ?

    Rich P

    Friday, July 17, 2015 5:57 PM