System.ServiceModel.AddressAccessDeniedException: HTTP konnte URL http :: 8080 nicht registrieren

Ich habe meine erste selbst-gehosteten WCF-Dienst. Ich veranstaltete es in einem C# Konsole-Anwendung, sondern es wirft einen Fehler:

System.ServiceModel.AddressAccessDeniedException: HTTP konnten Sie nicht registrieren, URL: http: 8080

Wenn ich Visual Studio 2013 als administrator, dann funktioniert es auch, aber nicht, wenn ich nicht. Also, jeder Weg, um bekommen es zu tun automatisch statt ab VS als ADMIN?

Bisher erstellte ich eine HelloService Klasse Bibliothek in der ich habe ein WCF-Dienst besteht in einer Schnittstelle IHelloService und HelloService.

IHelloService:

namespace HelloService
{
    [ServiceContract]
    public interface IHelloService
    {
        [OperationContract]
        String GetMsg();
    }
}

HelloService:

namespace HelloService
{
    public class HelloService : IHelloService
    {
        public String GetMsg()
        {
            return "Service Accessed";
        }
    }
}

Dann erstellte ich eine C# - Konsolenanwendung HelloServiceHost hat eine app.config Datei:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.serviceModel>
    <behaviors>
      <serviceBehaviors >
        <behavior name="MexBehaviour">
          <serviceMetadata httpGetEnabled="true"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <services>
      <service name="HelloService.HelloService" 
               behaviorConfiguration="MexBehaviour" >
        <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:8081/"/>
          </baseAddresses>
        </host>
      </service>
    </services>
  </system.serviceModel>
</configuration> 

und Programm.cs-Datei:

using HelloService;
using System.ServiceModel;

namespace HelloServiceHost
{
    class Program
    {
        static void Main(string[] args)
        {
            using(ServiceHost sh = new ServiceHost(typeof(HelloService.HelloService)))
            {
                sh.Open();
                Console.WriteLine("Host Started @"+ System.DateTime.UtcNow.ToShortDateString());
                sh.Close();
            }
        }
    }
}

Folgte ich ein video-tutorial, genau das, aber es funktioniert nicht, warum ?

Ich bin mit VS 2013, .net 4

InformationsquelleAutor der Frage user3432348 | 2014-03-27

Schreibe einen Kommentar