托管WCF服务时获取异常 [英] Getting Exception while hosting WCF service

查看:113
本文介绍了托管WCF服务时获取异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我正在尝试学习wcf服务。托管wcf服务时,我遇到了异常。



错误:System.ServiceModel.dll中发生了'System.ServiceModel.AddressAccessDeniedException'类型的未处理异常

其他信息:HTTP无法注册URL http:// +:8080 /。您的进程没有此命名空间的访问权限(有关详细信息,请参阅http://go.microsoft.com/fwlink/?LinkId=70353)。



这是我在app.config文件中的代码。



App.config



 <   system。 serviceModel  >  
< 服务 >
< 服务 名称 = HelloService.HelloService behaviorConfiguration = mexBehavior >
< endpoint 地址 = HelloService binding = basicHttpBinding 合同 = HelloService.IHelloService >
< /端点 >
< endpoint 地址 = HelloService binding = netTcpBinding contract = HelloService.IHelloService >
< / endpoint >
< endpoint 添加ress = mex binding = mexHttpBinding 合同 = IMetadataExchange >
< / endpoint >
< 主机 >
< baseAddresses >
< < span class =code-leadattribute> add baseAddress = http: // localhost:8080 / / >
< add baseAddress = net.tcp:// localhost:8090 / / >
< / baseAddresses >
< / host >
< / service >
< / services >
< 行为 >
< serviceBehaviors >
< 行为 名称 = mexBehavior >
< serviceMetadata < span class =code-attribute> httpGetEnabled = true / >
< / behavior >
< / serviceBehaviors >
< / behavior >
< / system.serviceModel >



< br $>


Program.cs

  class  < span class =code-leadattribute> Program  
{
static void Main()
{
using(ServiceHost host = new ServiceHost(typeof(HelloService HelloService)))
{
host Open();
控制台 .WriteLine(主机已启动 @ + DateTime 现在 .ToString());
控制台 .ReadLine();
}
}
}

解决方案

可能是因为操作系统的安全设置和用户帐户的访问级别该程序正在运行。



以下是一些可能对您有帮助的链接。



https://thetechnocrate.wordpress.com/2012/07 / 16 / system-servicemodel-addressaccessdeniedexception-http-could-not-register-url / [ ^ ]



http://stackoverflow.com/questions/609750/getting-system-servicemodel-addressaccessdeniedexception-on-vista-for-wcf-servic [ ^ ]

Hi,

I am trying to learn wcf services. While hosting wcf service I am getting exception.

Error: " An unhandled exception of type 'System.ServiceModel.AddressAccessDeniedException' occurred in System.ServiceModel.dll
Additional information: HTTP could not register URL http://+:8080/. Your process does not have access rights to this namespace (see http://go.microsoft.com/fwlink/?LinkId=70353 for details)."

Here is my code in app.config file.

App.config

<system.serviceModel>
      <services>
        <service name="HelloService.HelloService" behaviorConfiguration="mexBehavior">
          <endpoint address="HelloService" binding="basicHttpBinding" contract="HelloService.IHelloService">
          </endpoint>
          <endpoint address="HelloService" binding="netTcpBinding" contract="HelloService.IHelloService">
          </endpoint>
          <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange">
          </endpoint>
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8080/"/>
            <add baseAddress="net.tcp://localhost:8090/"/>
          </baseAddresses>
        </host>
        </service>
      </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="mexBehavior">
          <serviceMetadata httpGetEnabled="true"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    </system.serviceModel>




Program.cs

class Program
    {
        static void Main()
        {
            using(ServiceHost host= new ServiceHost(typeof(HelloService.HelloService)))
            {
                host.Open();
                Console.WriteLine("Host started @ " + DateTime.Now.ToString());
                Console.ReadLine();
            }
        }
    }

解决方案

It can be because of the security settings of the OS and the access level of the user account under which the program is running.

Here are some links that may help you.

https://thetechnocrate.wordpress.com/2012/07/16/system-servicemodel-addressaccessdeniedexception-http-could-not-register-url/[^]

http://stackoverflow.com/questions/609750/getting-system-servicemodel-addressaccessdeniedexception-on-vista-for-wcf-servic[^]


这篇关于托管WCF服务时获取异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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