HTTP 无法注册 URL http://+:8000/HelloWCF/.您的进程无权访问此命名空间 [英] HTTP could not register URL http://+:8000/HelloWCF/. Your process does not have access rights to this namespace

查看:20
本文介绍了HTTP 无法注册 URL http://+:8000/HelloWCF/.您的进程无权访问此命名空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 WCF 的初学者,但正在努力改进我的体验.在第一步我遇到了这个问题.我创建了最简单的 WCF 服务.代码清单:(所有代码在一个文件中)

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 无法注册 URL http://+:8000/HelloWCF/.您的进程无权访问此命名空间.

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.

推荐答案

不幸的是异常文本中的链接,http://go.microsoft.com/fwlink/?LinkId=70353,已损坏.但是,它曾经导致 http://msdn.microsoft.com/en-us/library/ms733768.aspx 解释了如何设置权限.

Unfortunately the link in the exception text, http://go.microsoft.com/fwlink/?LinkId=70353, is broken. However, it used to lead to http://msdn.microsoft.com/en-us/library/ms733768.aspx which explains how to set the permissions.

它基本上会通知您使用以下命令:

It basically informs you to use the following command:

netsh http add urlacl url=http://+:80/MyUri user=DOMAIN\user

你可以使用netsh

例如:netsh http add ?

提供有关 http add 命令的帮助.

Gives help on the http add command.

这篇关于HTTP 无法注册 URL http://+:8000/HelloWCF/.您的进程无权访问此命名空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆