I have self hosted a WCF service from a console application (HOST). I am calling HOST from another console application (PARENT). When I run PARENT, everything works fine like the WCF hosted successfully and instance of service reference is also getting created. The PARENT application is actually a plug-in for another big unmanaged application(BIG A). When I start the PARENT application from BIG A , the console application self hosts the service successfully. However I am getting following error while creating the instance of service.
Could not find default endpoint element that references contract 'CalculatorServiceReference.ICalculatorService' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element.
The configuration files are as follows.
•Configuration file of HOST
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="NewBehavior">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="NewBehavior" name="HybridCalcService.CalculatorService">
<clear />
<endpoint address="mex" binding="mexHttpBinding" name="Mex" contract="IMetadataExchange"
listenUriMode="Explicit">
</endpoint>
<endpoint address="net.tcp://localhost:8523/CalcService" binding="netTcpBinding"
name="Tcp" contract="HybridCalcService.ICalculatorService" listenUriMode="Explicit">
</endpoint>
<endpoint address="HTTP" binding="basicHttpBinding" bindingConfiguration=""
name="HTTP" contract="HybridCalcService.ICalculatorService" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8080/Hybridservice" />
</baseAddresses>
</host>
</service>
</services>
</system.serviceModel>
</configuration>
•And the config of PARENT is
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="NewBehavior">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="NewBehavior" name="HybridCalcService.CalculatorService">
<clear />
<endpoint address="mex" binding="mexHttpBinding" name="Mex"开发者_StackOverflow contract="IMetadataExchange"
listenUriMode="Explicit">
</endpoint>
<endpoint address="net.tcp://localhost:8523/CalcService" binding="netTcpBinding"
name="Tcp" contract="HybridCalcService.ICalculatorService" listenUriMode="Explicit">
</endpoint>
<endpoint address="HTTP" binding="basicHttpBinding" bindingConfiguration=""
name="HTTP" contract="HybridCalcService.ICalculatorService" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8080/Hybridservice" />
</baseAddresses>
</host>
</service>
</services>
</system.serviceModel>
</configuration>
Can anyone help me in this issue?
I believe that the config info has to be in the config file of the main application. Adding that info to the config of BigA should solve the problem.
This looks pretty similar to what I did for a custom channel. if i remember correctly this would go into HOST, and then you wouldn't need anything in the other configs.
精彩评论