5

using (ServiceHost host = new ServiceHost(typeof(HelloService.HelloService)))以下のコードで例外を取得するのを手伝ってください

例外 : ベース アドレスとして使用できるのは絶対 URI のみです。

WCF ホスト アプリケーション

    class Program
    {
        static void Main()
        {
            using (ServiceHost host = new ServiceHost(typeof(HelloService.HelloService)))
            {
                host.Open();
                Console.WriteLine("Service Started");
                Console.ReadLine();
            }
        }
    }

契約の実施

    public class HelloService : IHelloService
    {
        public string GetMessage(string Name)
        {
            return "Hello" + Name;
        }
    }

契約

[ServiceContract]
    public interface IHelloService
    {
        [OperationContract]
        string GetMessage(string Name);
    }

App.Config

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.serviceModel>
    <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/HelloService"/>
            <add baseAddress="net.tcp//localhost:8090/HelloService"/>
          </baseAddresses>
        </host>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="mexBehaviour">
          <serviceMetadata httpGetEnabled="true"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
</configuration>
4

3 に答える 3

5

コロン ( :) が欠落していると思います:

<add baseAddress="net.tcp//localhost:8090/HelloService"/>

する必要があります

<add baseAddress="net.tcp://localhost:8090/HelloService"/>
于 2015-06-12T21:06:15.950 に答える
0

要するにベースアドレスに関するエラーですので、ベースアドレスが正しく入力されているか確認してください。

エラー:

<add baseAddress=" &quot;http://localhost:8732/Design_Time_Addresses/WcfServiceLibraryShop/IStudent/&quot;&gt;" />

解決済み:

<add baseAddress=" http://localhost:8732/Design_Time_Addresses/WcfServiceLibraryShop/IStudent/" />
于 2018-10-04T19:45:49.780 に答える