端点为空?

发布于 2024-12-25 15:58:49 字数 4466 浏览 2 评论 0原文

我收到以下错误:

ChannelFactory.Endpoint 上的 Address 属性为 null。 ChannelFactory 的 Endpoint 必须指定有效的地址

但是我有客户端端点的地址,这里发生了什么?

代码:

 ChannelFactory<CommService.ITwService> myChannelFactory 
 = new ChannelFactory<CommService.ITwService>();
 CommService.ITwService wcfClient1 = myChannelFactory.CreateChannel();

客户端:

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

  <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>
    <client>
      <endpoint address="http://localhost:8732/Design_Time_Addresses/CommService/Service1/"
        binding="wsHttpBinding" contract="CommService.ITwService"
        name="Super">
        <identity>
          <dns value="localhost" />
        </identity>
      </endpoint>
    </client>
    <services />
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- To avoid disclosing metadata information, 
          set the value below to false and remove the metadata endpoint above before deployment -->
          <serviceMetadata httpGetEnabled="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="False" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>

</configuration>

服务器:

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

    <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>
      <client>
        <endpoint address="http://localhost:8732/Design_Time_Addresses/CommService/Service1/"
          binding="wsHttpBinding" bindingConfiguration="" contract="CommService.ITwService"
          name="" kind="" endpointConfiguration="">
          <identity>
            <dns value="localhost" />
            <certificateReference storeName="My" storeLocation="LocalMachine"
              x509FindType="FindBySubjectDistinguishedName" />
          </identity>
        </endpoint>
      </client>
      <services>
        <service name="CommService.Service1">
          <endpoint address="SuperEndPoint" binding="wsHttpBinding" name="SuperEndPoint"
            contract="CommService.ITwService">
            <identity>
              <dns value="localhost" />
            </identity>
          </endpoint>
          <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
          <host>
            <baseAddresses>
              <add baseAddress="http://localhost:8732/Design_Time_Addresses/CommService/Service1/" />
            </baseAddresses>
          </host>
        </service>
      </services>
      <behaviors>
        <serviceBehaviors>
          <behavior>
            <!-- To avoid disclosing metadata information, 
            set the value below to false and remove the metadata endpoint above before deployment -->
            <serviceMetadata httpGetEnabled="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="False" />
          </behavior>
        </serviceBehaviors>
      </behaviors>
    </system.serviceModel>

  </configuration>

I get the following error:

The Address property on ChannelFactory.Endpoint was null. The ChannelFactory's Endpoint must have a valid Address specified

But I have an adress for the client endpoint, what is going on here?

Code:

 ChannelFactory<CommService.ITwService> myChannelFactory 
 = new ChannelFactory<CommService.ITwService>();
 CommService.ITwService wcfClient1 = myChannelFactory.CreateChannel();

Client:

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

  <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>
    <client>
      <endpoint address="http://localhost:8732/Design_Time_Addresses/CommService/Service1/"
        binding="wsHttpBinding" contract="CommService.ITwService"
        name="Super">
        <identity>
          <dns value="localhost" />
        </identity>
      </endpoint>
    </client>
    <services />
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- To avoid disclosing metadata information, 
          set the value below to false and remove the metadata endpoint above before deployment -->
          <serviceMetadata httpGetEnabled="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="False" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>

</configuration>

Server:

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

    <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>
      <client>
        <endpoint address="http://localhost:8732/Design_Time_Addresses/CommService/Service1/"
          binding="wsHttpBinding" bindingConfiguration="" contract="CommService.ITwService"
          name="" kind="" endpointConfiguration="">
          <identity>
            <dns value="localhost" />
            <certificateReference storeName="My" storeLocation="LocalMachine"
              x509FindType="FindBySubjectDistinguishedName" />
          </identity>
        </endpoint>
      </client>
      <services>
        <service name="CommService.Service1">
          <endpoint address="SuperEndPoint" binding="wsHttpBinding" name="SuperEndPoint"
            contract="CommService.ITwService">
            <identity>
              <dns value="localhost" />
            </identity>
          </endpoint>
          <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
          <host>
            <baseAddresses>
              <add baseAddress="http://localhost:8732/Design_Time_Addresses/CommService/Service1/" />
            </baseAddresses>
          </host>
        </service>
      </services>
      <behaviors>
        <serviceBehaviors>
          <behavior>
            <!-- To avoid disclosing metadata information, 
            set the value below to false and remove the metadata endpoint above before deployment -->
            <serviceMetadata httpGetEnabled="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="False" />
          </behavior>
        </serviceBehaviors>
      </behaviors>
    </system.serviceModel>

  </configuration>

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

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

发布评论

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

评论(1

猫瑾少女 2025-01-01 15:58:49

通过创建一个新项目解决了这个问题..创建文件并使用复制粘贴将代码复制到新项目..很奇怪。

solved this by creating a new project.. creating the files and copying the code to the new project using copy paste.. weird.

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