当我尝试创建服务的新实例时收到“ConfigurationErrorsException”。
编辑:我的应用程序和 WCF 服务不在同一台机器上。Wcf 服务在 Windows Server 2012 上运行。
我在 Windows 应用商店应用程序中的代码如下所示:
var api = new ServiceRef.MyTestServiceClient(ApiServiceClient.EndpointConfiguration.BasicHttpEndpoint);
我的 WCF 配置是(它作为 Windows 服务托管):
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<services>
<service name="MyTestService.MyTestService"
behaviorConfiguration="MyTestServiceBehavior">
<host>
<baseAddresses>
<add baseAddress="http://localhost:8000/"/>
</baseAddresses>
</host>
<endpoint address="" binding="basicHttpBinding"
name="BasicHttpEndpoint"
bindingConfiguration=""
contract="MyTestService.IMyTestService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding"
contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="MyTestServiceBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="False"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
完整的错误信息是:
为扩展 'Microsoft.VisualStudio.Diagnostics.ServiceModelSink.Behavior' 注册的类型 'Microsoft.VisualStudio.Diagnostics.ServiceModelSink.Behavior, Microsoft.VisualStudio.Diagnostics.ServiceModelSink, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' 可以不被加载。