终结点为null
本文关键字:null 结点 | 更新日期: 2023-09-27 18:19:44
我得到以下错误:
ChannelFactory.Endpoint上的Address属性为null。ChannelFactory的终结点必须具有指定的有效地址
但是我有一个客户端端点的地址,这里发生了什么
代码:
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>
通过创建一个新项目解决了这个问题。。创建文件并使用复制粘贴将代码复制到新项目中。。奇怪的