0
votes

I am trying to build a small WCF service and wanted to utilize it in a test application.

PFB service code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;

namespace HelloIndigo
{
    [ServiceContract(Namespace="http://www.thatindigoirl.com/samples/2006/06")]
    public interface IHelloIndigoService
    {
        [OperationContract]
        string HelloIndigo();
    }
    public class HelloIndigoService : IHelloIndigoService
    {
        public string HelloIndigo()
        {
            return "Hello indigo";
        }
    }
}

Host Code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;

namespace Host
{
    class Program
    {
        static void Main(string[] args)
        {
            using (ServiceHost host = new ServiceHost(typeof(HelloIndigo.HelloIndigoService), new Uri("http://localhost:8000/HelloIndigo")))
            {
                host.AddServiceEndpoint(typeof(HelloIndigo.IHelloIndigoService), new BasicHttpBinding(), @"HelloIndigoService");
                host.Open();
                Console.WriteLine("Press <ENTER> to terminate the service hosy");
                Console.ReadLine();
            }
        }
    }
}

Whenever I am trying to run Host I am getting below mentioned error in host.Open() statement.

HTTP could not register URL http://+:8000/HelloIndigo/. Your process does not have access rights to this namespace (see http://go.microsoft.com/fwlink/?LinkId=70353 for details).

Can anyone help me with this

1
If you post code, XML or data samples, please highlight those lines in the text editor and click on the "code samples" button ( { } ) on the editor toolbar to nicely format and syntax highlight it! - marc_s
The most important parts - the configs for the server and client side - are missing. Without those, we can only guess..... - marc_s
Have you clicked on the Microsoft link in the error message? It explains what it is about. - Josef Pfleger

1 Answers

0
votes

You need to run the host app with elevated privileges (i.e., "As Administrator"). Under Vista/Win7, only administrative accounts have the permission to register socket listeners.