I’m a beginner in WCF, but trying to improve my experience. And on the first step I faced the problem. I created the simplest WCF service. The listing of code: (all the code in one file)
using System;
using System.ServiceModel;
namespace EssentialWCF
{
[ServiceContract]
public interface IStockService
{
[OperationContract]
double GetPrice(string ticker);
}
public class StockService : IStockService
{
public double GetPrice(string ticker)
{
return 94.85;
}
}
class Service
{
static void Main(string[] args)
{
ServiceHost serviceHost = new ServiceHost(typeof(StockService),
new Uri("http://localhost:8000/HelloWCF"));
serviceHost.AddServiceEndpoint(typeof(IStockService), new BasicHttpBinding());
serviceHost.Open();
Console.WriteLine("To continue press ENTER");
serviceHost.Close();
}
}
}
That would be the service that give me a number via console. But debug give me the exception: (instead of number 🙂 )
HTTP could not register URL http://+:8000/HelloWCF/. Your process does not have access rights to this namespace.
Have you ever faced the same situation? I will be glad to see every advice.