我从控制台应用程序(HOST)自我托管了一个WCF服务。我从另一个控制台应用程序(PARENT)调用HOST。当我运行PARENT时,一切正常,就像WCF成功托管一样,服务引用实例也正在创建。 PARENT应用程序实际上是另一个大型非托管应用程序(BIG A)的插件。当我从BIG A启动PARENT应用程序时,控制台应用程序自己成功托管服务。但是,我在创建服务实例时遇到以下错误。
在ServiceModel客户端配置部分中找不到引用合同“CalculatorServiceReference.ICalculatorService”的默认端点元素。这可能是因为没有为您的应用程序找到配置文件,或者因为在客户端元素中找不到与此合同匹配的端点元素。
配置文件如下。
•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>
•PARENT的配置是
<?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>
有谁可以帮我解决这个问题?
答案 0 :(得分:0)
我相信配置信息必须在主应用程序的配置文件中。将该信息添加到BigA的配置应该可以解决问题。
This看起来与我为自定义渠道所做的非常相似。如果我没记错的话,这会进入HOST,然后你就不需要其他任何配置。