【发布时间】:2011-10-13 06:31:54
【问题描述】:
我有一个 REST 服务,并在我的 WPF 应用程序中添加了它的引用。但是,一旦我创建代理的客户端,它就会抛出错误,并且会抛出错误,因为我的客户端 app.config 是空的:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
</configuration>
客户端的这一行抛出错误:
HelloWorldClient client = new HelloWorldClient();
这是我在服务器端 web.config 的 system.servicemodel 部分:
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
<services>
<service name="WCFRestExample.HelloWorld">
<endpoint address="" binding="webHttpBinding" contract="WCFRestExample.IHelloWorld"/>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</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="true" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
谁能告诉我为什么 app.config 是空的?我也重新启动了VS2010,但没有运气。
注意:当我直接在浏览器中浏览它时,该服务正在运行。所以,服务器端服务没有问题。
提前致谢:)
【问题讨论】:
-
创建 ServiceReference 时,请检查 Visual Studio 输出窗口是否有警告和错误。即使您可能在错误列表中看不到任何内容,请检查输出窗口,您是否看到了什么?
-
@Dominik:不!什么都没有。