C# 在…上没有侦听可接受消息的终结点

C# 在…上没有侦听可接受消息的终结点,c#,visual-studio,wcf-endpoint,C#,Visual Studio,Wcf Endpoint,我是在VisualStudio中创建安装程序的初学者。当我尝试创建时,我遇到了一个错误“没有端点可以接受消息。 所以情况是我有一台连接到一台服务器(LAN)的5台pc。只能脱机使用 以下是我的app.config代码: <?xml version="1.0" encoding="utf-8"?> <configuration> <configSections> </configSections> <connection

我是在VisualStudio中创建安装程序的初学者。当我尝试创建时,我遇到了一个错误“没有端点可以接受消息。 所以情况是我有一台连接到一台服务器(LAN)的5台pc。只能脱机使用

以下是我的app.config代码:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <configSections>
    </configSections>
    <connectionStrings>
        <add name="eSample.Properties.Settings.Sampledb" connectionString="Data Source=(local)\SQL2008;Initial Catalog=Sampledb;User ID=sa;Password=password"
            providerName="System.Data.SqlClient" />
    </connectionStrings>
    <system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="BasicHttpBinding_IUserService" maxBufferPoolSize="20000000"
                    maxReceivedMessageSize="20000000" />                
            </basicHttpBinding>
        </bindings>
        <client>            
            <endpoint address="http://localhost:8733/eSARService/UserService/"
                binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IUserService"
                contract="UserServiceRef.IUserService" name="BasicHttpBinding_IUserService" />
            </client>
    </system.serviceModel>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Net.Http.Formatting" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
  <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --></configSections>
  <connectionStrings>
    <add name="SampledbEntities" connectionString="metadata=res://*/SampleModel.csdl|res://*/SampleModel.ssdl|res://*/SampleModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=(local)\SQL2008;initial catalog=Sampledb;persist security info=True;user id=sa;password=password;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
  </connectionStrings>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
    <providers>
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
    </providers>
  </entityFramework>
  <appSettings>
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
  </appSettings>
  <system.web>
    <compilation debug="true" />
  </system.web>
  <!-- When deploying the service library project, the content of the config file must be added to the host's 
  app.config file. System.Configuration does not support config files for libraries. -->
  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="dcBinding" maxBufferPoolSize="20000000" maxBufferSize="20000000"
          maxReceivedMessageSize="20000000">
          <readerQuotas maxDepth="32" maxStringContentLength="20000000"
            maxArrayLength="20000000" />
        </binding>
      </basicHttpBinding>
    </bindings>
    <services>
      <service name="eSARService.UserService">
        <endpoint address="" binding="basicHttpBinding" bindingConfiguration="dcBinding"
          contract="eSARService.IUserService">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8733/eSARService/UserService/" />
          </baseAddresses>
        </host>
      </service>          
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- To avoid disclosing metadata information, 
          set the values below to false before deployment -->
          <serviceMetadata httpGetEnabled="True" httpsGetEnabled="True" />
          <!-- To receive exception details in faults for debugging purposes, 
          set the value below to true.  Set to false before deployment 
          to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="True" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>

</configuration>

以下是我的服务的app.config:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <configSections>
    </configSections>
    <connectionStrings>
        <add name="eSample.Properties.Settings.Sampledb" connectionString="Data Source=(local)\SQL2008;Initial Catalog=Sampledb;User ID=sa;Password=password"
            providerName="System.Data.SqlClient" />
    </connectionStrings>
    <system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="BasicHttpBinding_IUserService" maxBufferPoolSize="20000000"
                    maxReceivedMessageSize="20000000" />                
            </basicHttpBinding>
        </bindings>
        <client>            
            <endpoint address="http://localhost:8733/eSARService/UserService/"
                binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IUserService"
                contract="UserServiceRef.IUserService" name="BasicHttpBinding_IUserService" />
            </client>
    </system.serviceModel>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Net.Http.Formatting" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
  <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --></configSections>
  <connectionStrings>
    <add name="SampledbEntities" connectionString="metadata=res://*/SampleModel.csdl|res://*/SampleModel.ssdl|res://*/SampleModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=(local)\SQL2008;initial catalog=Sampledb;persist security info=True;user id=sa;password=password;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
  </connectionStrings>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
    <providers>
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
    </providers>
  </entityFramework>
  <appSettings>
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
  </appSettings>
  <system.web>
    <compilation debug="true" />
  </system.web>
  <!-- When deploying the service library project, the content of the config file must be added to the host's 
  app.config file. System.Configuration does not support config files for libraries. -->
  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="dcBinding" maxBufferPoolSize="20000000" maxBufferSize="20000000"
          maxReceivedMessageSize="20000000">
          <readerQuotas maxDepth="32" maxStringContentLength="20000000"
            maxArrayLength="20000000" />
        </binding>
      </basicHttpBinding>
    </bindings>
    <services>
      <service name="eSARService.UserService">
        <endpoint address="" binding="basicHttpBinding" bindingConfiguration="dcBinding"
          contract="eSARService.IUserService">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8733/eSARService/UserService/" />
          </baseAddresses>
        </host>
      </service>          
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- To avoid disclosing metadata information, 
          set the values below to false before deployment -->
          <serviceMetadata httpGetEnabled="True" httpsGetEnabled="True" />
          <!-- To receive exception details in faults for debugging purposes, 
          set the value below to true.  Set to false before deployment 
          to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="True" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>

</configuration>


从该链接中找到了答案

是否有人在监听?您的eSARService/UserService可能未运行该服务是否公开元数据?@AllanS.Hansen当我通过visual studio运行该服务时,它工作正常,但当我在将安装程序安装到pc后运行它时……我看到了该错误