HTTP 无法注册 URL http://+:8000/HelloWCF/.您的进程无权访问此命名空间

编程入门 行业动态 更新时间:2024-10-26 17:36:08
本文介绍了HTTP 无法注册 URL http://+:8000/HelloWCF/.您的进程无权访问此命名空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我是 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/fwlink/?LinkId=70353,已损坏.但是,它曾经导致 http://msdn.microsoft/en-us/library/ms733768.aspx 解释了如何设置权限.

Unfortunately the link in the exception text, http://go.microsoft/fwlink/?LinkId=70353, is broken. However, it used to lead to http://msdn.microsoft/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屋!

更多推荐

[db:关键词]

本文发布于:2023-04-26 21:04:03,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1142807.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:您的   进程   空间   URL   HTTP

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!