Click here to Skip to main content
16,016,345 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi there.
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)
C#
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>.\n\n");

            serviceHost.Close();
        }
    }
}

That would be the service that give me a number via console. But debug give me the exception: (instead of number :) )
Quote:
HTTP could not register URL http://+:8000/HelloWCF/. Your process does not have access rights to this namespace (see http://go.microsoft.com/fwlink/?LinkId=70353 for details).

Have you ever faced the same situation? I will be glad to see every advice.
Thanks in advance.
Posted
Updated 7-Jul-18 23:36pm
Comments
Marcos Tito 10-Nov-16 10:07am    
Hi !

How about this error in a Web App on Azure?

How can I run netsh there?

Thank you!

Check this thread which contains many solutions
WCF ServiceHost access rights[^]
 
Share this answer
 
Comments
valecoder 4-Jan-12 8:22am    
Glad your link help me to fix that. Thanks.
Run application administration mode.

Right click on vs and run as administrator.
 
Share this answer
 
Comments
CHill60 15-Jul-13 14:29pm    
The question was resolved over a year ago with a much information.
chandankumarsahoo 18-Jul-14 2:36am    
Very very thanks
your solution slv my problem
Hi Guys,

Let me intrduse another solution.
Your user should not have Admin permissions and should not launch VS under Admin as well.

Follow these steps:
1. Get Admin CMD
2. her is a template of command you should run per each service you would like to launch

netsh http add urlacl url=http://+:8000/ServiceModelSamples/Service user=mylocaluser

- the port 8000 - may be different
- the ServiceModelSamples/Service - the name of service
- mylocaluser - you user name on PC
 
Share this answer
 
Just Save the Solution --> Close the VS --> again Right click on VS startup Icon --> select option "Run as Administrative" --> again open your WCF Host Project and RUN the Service
 
Share this answer
 
Comments
CHill60 9-Jul-18 4:13am    
Run as Admin was part of the accepted solution posted over 6 years ago. Stick to answering new posts where the OP still needs help, and make sure you are not just repeating something that has already been suggested
Member 13723018 4-Nov-18 21:58pm    
now it's working

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900