如何在局域网上启用 TCP

发布于 2024-12-10 07:52:38 字数 14816 浏览 0 评论 0原文

我已经为我的 WPF 应用程序编写了使用 WCF 的代码,wcf 作为 Windows 服务运行,我希望程序 wpf 在客户端计算机上运行。我在 PC 上安装了 WPF 应用程序以及服务和 sql 服务器,它在那里工作正常。但是,当我在另一台PC上安装wpf客户端时,客户端WPF无法连接到服务器。我的意思是 WCF Windows 服务不支持 LAN 使用,但我只是为了这个目的而设计它。请您检查我的代码并告诉我哪里出了问题。

WPF 应用程序代码:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <configSections>
        <sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
            <section name="WorkMateWPF.MySettings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
        </sectionGroup>
    </configSections>
    <system.diagnostics>
        <sources>
            <!-- This section defines the logging configuration for My.Application.Log -->
            <source name="DefaultSource" switchName="DefaultSwitch">
                <listeners>
                    <add name="FileLog"/>
                    <!-- Uncomment the below section to write to the Application Event Log -->
                    <!--<add name="EventLog"/>-->
                </listeners>
            </source>
        </sources>
        <switches>
            <add name="DefaultSwitch" value="Information" />
        </switches>
        <sharedListeners>
            <add name="FileLog"
                 type="Microsoft.VisualBasic.Logging.FileLogTraceListener, Microsoft.VisualBasic, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"
                 initializeData="FileLogWriter"/>
            <!-- Uncomment the below section and replace APPLICATION_NAME with the name of your application to write to the Application Event Log -->
            <!--<add name="EventLog" type="System.Diagnostics.EventLogTraceListener" initializeData="APPLICATION_NAME"/> -->
        </sharedListeners>
    </system.diagnostics>
    <system.serviceModel>
        <bindings>
            <netTcpBinding>
                <binding name="NetTcpBinding_IWCFBatchImport" closeTimeout="00:01:00"
                    openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                    transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions"
                    hostNameComparisonMode="StrongWildcard" listenBacklog="10"
                    maxBufferPoolSize="524288" maxBufferSize="65536" maxConnections="10"
                    maxReceivedMessageSize="65536">
                    <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                        maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                    <reliableSession ordered="true" inactivityTimeout="00:10:00"
                        enabled="false" />
                    <security mode="Transport">
                        <transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
                        <message clientCredentialType="Windows" />
                    </security>
                </binding>
                <binding name="NetTcpBinding_IWCFCourses" closeTimeout="00:01:00"
                    openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                    transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions"
                    hostNameComparisonMode="StrongWildcard" listenBacklog="10"
                    maxBufferPoolSize="524288" maxBufferSize="65536" maxConnections="10"
                    maxReceivedMessageSize="65536">
                    <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                        maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                    <reliableSession ordered="true" inactivityTimeout="00:10:00"
                        enabled="false" />
                    <security mode="Transport">
                        <transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
                        <message clientCredentialType="Windows" />
                    </security>
                </binding>
                <binding name="NetTcpBinding_IWCFFaculty" closeTimeout="00:01:00"
                    openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                    transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions"
                    hostNameComparisonMode="StrongWildcard" listenBacklog="10"
                    maxBufferPoolSize="524288" maxBufferSize="65536" maxConnections="10"
                    maxReceivedMessageSize="65536">
                    <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                        maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                    <reliableSession ordered="true" inactivityTimeout="00:10:00"
                        enabled="false" />
                    <security mode="Transport">
                        <transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
                        <message clientCredentialType="Windows" />
                    </security>
                </binding>
                <binding name="NetTcpBinding_IWCFLogin" closeTimeout="00:01:00"
                    openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                    transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions"
                    hostNameComparisonMode="StrongWildcard" listenBacklog="10"
                    maxBufferPoolSize="524288" maxBufferSize="65536" maxConnections="10"
                    maxReceivedMessageSize="65536">
                    <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                        maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                    <reliableSession ordered="true" inactivityTimeout="00:10:00"
                        enabled="false" />
                    <security mode="Transport">
                        <transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
                        <message clientCredentialType="Windows" />
                    </security>
                </binding>
                <binding name="NetTcpBinding_IWCFStudent" closeTimeout="00:01:00"
                    openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                    transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions"
                    hostNameComparisonMode="StrongWildcard" listenBacklog="10"
                    maxBufferPoolSize="524288" maxBufferSize="65536" maxConnections="10"
                    maxReceivedMessageSize="65536">
                    <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                        maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                    <reliableSession ordered="true" inactivityTimeout="00:10:00"
                        enabled="false" />
                    <security mode="Transport">
                        <transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
                        <message clientCredentialType="Windows" />
                    </security>
                </binding>
            </netTcpBinding>
        </bindings>
        <client>
            <endpoint address="net.tcp://localhost:8732/WCFBatchImports"
                binding="netTcpBinding" bindingConfiguration="NetTcpBinding_IWCFBatchImport"
                contract="ServiceBatchImports.IWCFBatchImport" name="NetTcpBinding_IWCFBatchImport">
                <identity>
                    <dns value="localhost" />
                </identity>
            </endpoint>
            <endpoint address="net.tcp://localhost:8732/WCFCourses" binding="netTcpBinding"
                bindingConfiguration="NetTcpBinding_IWCFCourses" contract="ServiceCourses.IWCFCourses"
                name="NetTcpBinding_IWCFCourses">
                <identity>
                    <dns value="localhost" />
                </identity>
            </endpoint>
            <endpoint address="net.tcp://localhost:8732/WCFFaculty" binding="netTcpBinding"
                bindingConfiguration="NetTcpBinding_IWCFFaculty" contract="ServiceFaculty.IWCFFaculty"
                name="NetTcpBinding_IWCFFaculty">
                <identity>
                    <dns value="localhost" />
                </identity>
            </endpoint>
            <endpoint address="net.tcp://localhost:8732/WCFLogin" binding="netTcpBinding"
                bindingConfiguration="NetTcpBinding_IWCFLogin" contract="ServiceLogins.IWCFLogin"
                name="NetTcpBinding_IWCFLogin">
                <identity>
                    <dns value="localhost" />
                </identity>
            </endpoint>
            <endpoint address="net.tcp://localhost:8732/WCFStudents" binding="netTcpBinding"
                bindingConfiguration="NetTcpBinding_IWCFStudent" contract="ServiceStudents.IWCFStudent"
                name="NetTcpBinding_IWCFStudent">
                <identity>
                    <dns value="localhost" />
                </identity>
            </endpoint>
        </client>
    </system.serviceModel>
    <userSettings>
        <WorkMateWPF.MySettings>
            <setting name="Test" serializeAs="String">
                <value />
            </setting>
        </WorkMateWPF.MySettings>
    </userSettings>
</configuration>

以下是服务应用程序代码:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>

  <configSections>
  </configSections>
  <connectionStrings>
    <add name="WorkMateWCF.My.MySettings.workmateConnectionString"
      connectionString="Data Source=PAVAN-PC;Initial Catalog=WorkMate;Persist Security Info=True;User ID=WorkMateUser;Password=workmateuser"
      providerName="System.Data.SqlClient" />
  </connectionStrings>
  <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>
    <services>
      <service name="WorkMateWCF.WCFLogin">
        <endpoint address="" binding="netTcpBinding" bindingConfiguration=""
          contract="WorkMateWCF.IWCFLogin">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexTcpBinding" bindingConfiguration=""
          contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="net.tcp://localhost:8732/WCFLogin" />
          </baseAddresses>
        </host>
      </service>
      <service name="WorkMateWCF.WCFCourses">
        <endpoint address="" binding="netTcpBinding" bindingConfiguration=""
          contract="WorkMateWCF.IWCFCourses">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexTcpBinding" bindingConfiguration=""
          contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="net.tcp://localhost:8732/WCFCourses" />
          </baseAddresses>
        </host>
      </service>
      <service name="WorkMateWCF.WCFStudent">
        <endpoint address="" binding="netTcpBinding" bindingConfiguration=""
          contract="WorkMateWCF.IWCFStudent">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexTcpBinding" bindingConfiguration=""
          contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="net.tcp://localhost:8732/WCFStudents" />
          </baseAddresses>
        </host>
      </service>
      <service name="WorkMateWCF.WCFBatchImport">
        <endpoint address="" binding="netTcpBinding" bindingConfiguration=""
          contract="WorkMateWCF.IWCFBatchImport">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexTcpBinding" bindingConfiguration=""
          contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="net.tcp://localhost:8732/WCFBatchImports" />
          </baseAddresses>
        </host>
      </service>
      <service name="WorkMateWCF.WCFFaculty">
        <endpoint address="" binding="netTcpBinding" bindingConfiguration=""
          contract="WorkMateWCF.IWCFFaculty">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexTcpBinding" bindingConfiguration=""
          contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="net.tcp://localhost:8732/WCFFaculty" />
          </baseAddresses>
        </host>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="">
          <serviceMetadata httpGetEnabled="false" httpsGetEnabled="false" />
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>

</configuration>

期待有需要的人。谢谢。

I have written a code for my WPF App to use WCF, wcf is running as Windows service, I want the program wpf to run on client machines. I installed WPF app on PC along with the service and sql server, it is working fine in there. However, when I installed the wpf client on another PC, the client WPF is not able to connect to the server. I mean the WCF windows service is not support for lan usage, however I designed it for this intention only. Could you please check my code and tell me where I have gone wrong please.

WPF App code:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <configSections>
        <sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
            <section name="WorkMateWPF.MySettings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
        </sectionGroup>
    </configSections>
    <system.diagnostics>
        <sources>
            <!-- This section defines the logging configuration for My.Application.Log -->
            <source name="DefaultSource" switchName="DefaultSwitch">
                <listeners>
                    <add name="FileLog"/>
                    <!-- Uncomment the below section to write to the Application Event Log -->
                    <!--<add name="EventLog"/>-->
                </listeners>
            </source>
        </sources>
        <switches>
            <add name="DefaultSwitch" value="Information" />
        </switches>
        <sharedListeners>
            <add name="FileLog"
                 type="Microsoft.VisualBasic.Logging.FileLogTraceListener, Microsoft.VisualBasic, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"
                 initializeData="FileLogWriter"/>
            <!-- Uncomment the below section and replace APPLICATION_NAME with the name of your application to write to the Application Event Log -->
            <!--<add name="EventLog" type="System.Diagnostics.EventLogTraceListener" initializeData="APPLICATION_NAME"/> -->
        </sharedListeners>
    </system.diagnostics>
    <system.serviceModel>
        <bindings>
            <netTcpBinding>
                <binding name="NetTcpBinding_IWCFBatchImport" closeTimeout="00:01:00"
                    openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                    transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions"
                    hostNameComparisonMode="StrongWildcard" listenBacklog="10"
                    maxBufferPoolSize="524288" maxBufferSize="65536" maxConnections="10"
                    maxReceivedMessageSize="65536">
                    <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                        maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                    <reliableSession ordered="true" inactivityTimeout="00:10:00"
                        enabled="false" />
                    <security mode="Transport">
                        <transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
                        <message clientCredentialType="Windows" />
                    </security>
                </binding>
                <binding name="NetTcpBinding_IWCFCourses" closeTimeout="00:01:00"
                    openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                    transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions"
                    hostNameComparisonMode="StrongWildcard" listenBacklog="10"
                    maxBufferPoolSize="524288" maxBufferSize="65536" maxConnections="10"
                    maxReceivedMessageSize="65536">
                    <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                        maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                    <reliableSession ordered="true" inactivityTimeout="00:10:00"
                        enabled="false" />
                    <security mode="Transport">
                        <transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
                        <message clientCredentialType="Windows" />
                    </security>
                </binding>
                <binding name="NetTcpBinding_IWCFFaculty" closeTimeout="00:01:00"
                    openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                    transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions"
                    hostNameComparisonMode="StrongWildcard" listenBacklog="10"
                    maxBufferPoolSize="524288" maxBufferSize="65536" maxConnections="10"
                    maxReceivedMessageSize="65536">
                    <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                        maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                    <reliableSession ordered="true" inactivityTimeout="00:10:00"
                        enabled="false" />
                    <security mode="Transport">
                        <transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
                        <message clientCredentialType="Windows" />
                    </security>
                </binding>
                <binding name="NetTcpBinding_IWCFLogin" closeTimeout="00:01:00"
                    openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                    transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions"
                    hostNameComparisonMode="StrongWildcard" listenBacklog="10"
                    maxBufferPoolSize="524288" maxBufferSize="65536" maxConnections="10"
                    maxReceivedMessageSize="65536">
                    <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                        maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                    <reliableSession ordered="true" inactivityTimeout="00:10:00"
                        enabled="false" />
                    <security mode="Transport">
                        <transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
                        <message clientCredentialType="Windows" />
                    </security>
                </binding>
                <binding name="NetTcpBinding_IWCFStudent" closeTimeout="00:01:00"
                    openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                    transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions"
                    hostNameComparisonMode="StrongWildcard" listenBacklog="10"
                    maxBufferPoolSize="524288" maxBufferSize="65536" maxConnections="10"
                    maxReceivedMessageSize="65536">
                    <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                        maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                    <reliableSession ordered="true" inactivityTimeout="00:10:00"
                        enabled="false" />
                    <security mode="Transport">
                        <transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
                        <message clientCredentialType="Windows" />
                    </security>
                </binding>
            </netTcpBinding>
        </bindings>
        <client>
            <endpoint address="net.tcp://localhost:8732/WCFBatchImports"
                binding="netTcpBinding" bindingConfiguration="NetTcpBinding_IWCFBatchImport"
                contract="ServiceBatchImports.IWCFBatchImport" name="NetTcpBinding_IWCFBatchImport">
                <identity>
                    <dns value="localhost" />
                </identity>
            </endpoint>
            <endpoint address="net.tcp://localhost:8732/WCFCourses" binding="netTcpBinding"
                bindingConfiguration="NetTcpBinding_IWCFCourses" contract="ServiceCourses.IWCFCourses"
                name="NetTcpBinding_IWCFCourses">
                <identity>
                    <dns value="localhost" />
                </identity>
            </endpoint>
            <endpoint address="net.tcp://localhost:8732/WCFFaculty" binding="netTcpBinding"
                bindingConfiguration="NetTcpBinding_IWCFFaculty" contract="ServiceFaculty.IWCFFaculty"
                name="NetTcpBinding_IWCFFaculty">
                <identity>
                    <dns value="localhost" />
                </identity>
            </endpoint>
            <endpoint address="net.tcp://localhost:8732/WCFLogin" binding="netTcpBinding"
                bindingConfiguration="NetTcpBinding_IWCFLogin" contract="ServiceLogins.IWCFLogin"
                name="NetTcpBinding_IWCFLogin">
                <identity>
                    <dns value="localhost" />
                </identity>
            </endpoint>
            <endpoint address="net.tcp://localhost:8732/WCFStudents" binding="netTcpBinding"
                bindingConfiguration="NetTcpBinding_IWCFStudent" contract="ServiceStudents.IWCFStudent"
                name="NetTcpBinding_IWCFStudent">
                <identity>
                    <dns value="localhost" />
                </identity>
            </endpoint>
        </client>
    </system.serviceModel>
    <userSettings>
        <WorkMateWPF.MySettings>
            <setting name="Test" serializeAs="String">
                <value />
            </setting>
        </WorkMateWPF.MySettings>
    </userSettings>
</configuration>

Following is the service app code:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>

  <configSections>
  </configSections>
  <connectionStrings>
    <add name="WorkMateWCF.My.MySettings.workmateConnectionString"
      connectionString="Data Source=PAVAN-PC;Initial Catalog=WorkMate;Persist Security Info=True;User ID=WorkMateUser;Password=workmateuser"
      providerName="System.Data.SqlClient" />
  </connectionStrings>
  <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>
    <services>
      <service name="WorkMateWCF.WCFLogin">
        <endpoint address="" binding="netTcpBinding" bindingConfiguration=""
          contract="WorkMateWCF.IWCFLogin">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexTcpBinding" bindingConfiguration=""
          contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="net.tcp://localhost:8732/WCFLogin" />
          </baseAddresses>
        </host>
      </service>
      <service name="WorkMateWCF.WCFCourses">
        <endpoint address="" binding="netTcpBinding" bindingConfiguration=""
          contract="WorkMateWCF.IWCFCourses">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexTcpBinding" bindingConfiguration=""
          contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="net.tcp://localhost:8732/WCFCourses" />
          </baseAddresses>
        </host>
      </service>
      <service name="WorkMateWCF.WCFStudent">
        <endpoint address="" binding="netTcpBinding" bindingConfiguration=""
          contract="WorkMateWCF.IWCFStudent">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexTcpBinding" bindingConfiguration=""
          contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="net.tcp://localhost:8732/WCFStudents" />
          </baseAddresses>
        </host>
      </service>
      <service name="WorkMateWCF.WCFBatchImport">
        <endpoint address="" binding="netTcpBinding" bindingConfiguration=""
          contract="WorkMateWCF.IWCFBatchImport">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexTcpBinding" bindingConfiguration=""
          contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="net.tcp://localhost:8732/WCFBatchImports" />
          </baseAddresses>
        </host>
      </service>
      <service name="WorkMateWCF.WCFFaculty">
        <endpoint address="" binding="netTcpBinding" bindingConfiguration=""
          contract="WorkMateWCF.IWCFFaculty">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexTcpBinding" bindingConfiguration=""
          contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="net.tcp://localhost:8732/WCFFaculty" />
          </baseAddresses>
        </host>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="">
          <serviceMetadata httpGetEnabled="false" httpsGetEnabled="false" />
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>

</configuration>

Looking forward for the needfull. Thank you.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

被你宠の有点坏 2024-12-17 07:52:38

看来您的所有服务地址在服务和客户端配置文件中都设置为 localhost。本地主机始终指的是程序正在运行的机器。

您需要为服务使用正确的计算机名称并在客户端中引用它。

例如,假设您的服务托管在网络上具有以下地址的计算机上 - myservicebox:8732。该服务的配置文件如下所示:

<service name="WorkMateWCF.WCFLogin">
  <endpoint address="" binding="netTcpBinding" bindingConfiguration=""
            contract="WorkMateWCF.IWCFLogin">
    <identity>
      <dns value="myservicebox" />
    </identity>
  </endpoint>
  <endpoint address="mex" binding="mexTcpBinding" bindingConfiguration=""
            contract="IMetadataExchange" />
    <host>
      <baseAddresses>
        <add baseAddress="net.tcp://myservicbox:8732/WCFLogin" />
      </baseAddresses>
    </host>
  </service>

然后,您将在希望使用该服务的客户端中引用 net.tcp://myservicebox:8732/WCFLogin

另请注意,您的服务(基于您发布的配置文件)将使用指定绑定的默认值,如果您需要不同的值(例如更大的消息大小等),这可能会给您带来问题。

当您通过 bindingConfiguration 属性将它们分配给客户端端点时,您的客户端配置将使用您设置的绑定。

在您的情况下不一定是问题(乍一看,您似乎正在使用客户端上的默认值),但需要注意一些事情。

It appears that all of your service addresses are set to localhost, in both the service and the client config files. Localhost always refers to the machine the program is running on.

You'll need to use the correct machine name for the service and reference it in the client.

For example, say your service is hosted on a machine on the network with the following address - myservicebox:8732. The service's config file would look like this:

<service name="WorkMateWCF.WCFLogin">
  <endpoint address="" binding="netTcpBinding" bindingConfiguration=""
            contract="WorkMateWCF.IWCFLogin">
    <identity>
      <dns value="myservicebox" />
    </identity>
  </endpoint>
  <endpoint address="mex" binding="mexTcpBinding" bindingConfiguration=""
            contract="IMetadataExchange" />
    <host>
      <baseAddresses>
        <add baseAddress="net.tcp://myservicbox:8732/WCFLogin" />
      </baseAddresses>
    </host>
  </service>

You would then reference net.tcp://myservicebox:8732/WCFLogin in your client(s) that wish to utilize the service.

Also, note that your service (based on your posted config file) will be using the default values for the specified bindings, which may cause problems for you if you need different values (like bigger message size, etc).

Your client config will use the bindings you've set up as you assign them to the client endpoints via the bindingConfiguration attribute.

Not necessarily a problem in your case (and it looks like you're using the default values on the client anyway, at a quick glance), but something to be aware of.

白色秋天 2024-12-17 07:52:38

后来我检查了事件日志,问题出在绑定时间上,我将其更改为 00:10:00,它似乎有效,但这次我遇到了一个新错误,它与这个问题无关。

I later checked the event logs and the issue was with the time on binding and I changed it to 00:10:00 and it seems to work, but this time I landed on a new error and it does not relate to this question.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文