WCF and Windows Store apps, ConfigurationErrorsException
本文关键字:ConfigurationErrorsException apps Store and Windows WCF | 更新日期: 2023-09-27 18:17:45
当我尝试创建服务的新实例时,我得到一个"ConfigurationErrorsException"。
编辑:我的应用程序和WCF服务不在同一台机器上。Wcf服务在Windows Server 2012上运行我在Windows Store应用程序中的代码是这样的:
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。= 4.0.0.0 ServiceModelSink,版本,文化=中性,PublicKeyToken=b03f5f7f11d50a3a'注册为扩展"Microsoft.VisualStudio.Diagnostics.ServiceModelSink。行为的可能未加载
我也遇到了同样的问题。以下步骤已为我解决了问题:
- Close Visual Studio
- 删除。suo和。csproj文件。用户文件
- 重启Visual Studio
- 重建项目
这可能是因为引用的程序集不是"。. NET for Windows Store apps"库。根据此,http://msdn.microsoft.com/en-us/library/windows/apps/br230302(v=vs.110).aspx,不支持诊断:包装操作系统功能的类型和成员(如system . diagnostics . eventlog和性能计数器)。