Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/264.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/wcf/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 通过配置为WCF服务指定运行时地址_C#_Wcf_App Config - Fatal编程技术网

C# 通过配置为WCF服务指定运行时地址

C# 通过配置为WCF服务指定运行时地址,c#,wcf,app-config,C#,Wcf,App Config,我已经使用VS2010C创建了一个WCF库,并从其他项目中引用了它,所有这些都在designtime上运行良好。但在运行时,据我所知,它使用不同的地址。那么,我如何指定它呢 我的App.Config看起来像: 运行时,您的服务是否在同一端口上运行?如果您在IIS中托管它,它可能是端口80。@Marko不,我只是从同一个解决方案中引用它,因此,如果我理解正确,它不会使用IISIt,只有在您托管它时,它才会使用不同的地址。如果您继续在调试模式下从VS运行它,它将继续使用相同的端口。@abhi我编

我已经使用VS2010C创建了一个WCF库,并从其他项目中引用了它,所有这些都在designtime上运行良好。但在运行时,据我所知,它使用不同的地址。那么,我如何指定它呢

我的App.Config看起来像:


运行时,您的服务是否在同一端口上运行?如果您在IIS中托管它,它可能是端口80。@Marko不,我只是从同一个解决方案中引用它,因此,如果我理解正确,它不会使用IISIt,只有在您托管它时,它才会使用不同的地址。如果您继续在调试模式下从VS运行它,它将继续使用相同的端口。@abhi我编译它,从.exe运行它并获取EndpointNotFoundException。
  <system.web>
    <compilation debug="true" />
  </system.web>
  <system.serviceModel>
    <services>
      <service name="WcfService.Service1">
        <host>
          <baseAddresses>
            <add baseAddress = "http://localhost:8732/Design_Time_Addresses/WcfService/MyWcf/" />
          </baseAddresses>
        </host>
        <endpoint address ="" binding="wsHttpBinding" contract="WcfService.IService1">
        </endpoint>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <serviceMetadata httpGetEnabled="True"/>
          <serviceDebug includeExceptionDetailInFaults="False" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>

</configuration>