Web services 创建代理类的实例时出错

Web services 创建代理类的实例时出错,web-services,wcf,rest,asp.net-mvc-5,windows-forms-designer,Web Services,Wcf,Rest,Asp.net Mvc 5,Windows Forms Designer,这就是错误: The type initializer for 'System.ServiceModel.Diagnostics.TraceUtility' threw an exception. 当我尝试实例我的代理类时,会发生此错误 namespace TesteWebService { public partial class Form1 : Form { public Form1() { InitializeCom

这就是错误:

The type initializer for 'System.ServiceModel.Diagnostics.TraceUtility' threw an exception.
当我尝试实例我的代理类时,会发生此错误

namespace TesteWebService
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void btnPdv_Click(object sender, EventArgs e)
        {
            SuporteTecnicoClientProxy proxy = new SuporteTecnicoClientProxy();=> **Here error**

                try
                {
                    TPDV pdv = proxy.getCnpjParceiro(txtCnpj.Text);
                    lblRazao.Text = pdv.RazaoSocial;
                    lblEndereco.Text = pdv.Endereco;
                }
                catch (Exception ex)
                { }
                finally
                { }
        }
    }
}
namespace TesteWebService
{
    class SuporteTecnicoClientProxy : ClientBase<ISuporteTecnicoContract>, ISuporteTecnicoContract
    {
        public TPDV getCnpjParceiro(string _cnpj)
        {
            return this.Channel.getCnpjParceiro(_cnpj);
        }
    }
}
我的代理类

namespace TesteWebService
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void btnPdv_Click(object sender, EventArgs e)
        {
            SuporteTecnicoClientProxy proxy = new SuporteTecnicoClientProxy();=> **Here error**

                try
                {
                    TPDV pdv = proxy.getCnpjParceiro(txtCnpj.Text);
                    lblRazao.Text = pdv.RazaoSocial;
                    lblEndereco.Text = pdv.Endereco;
                }
                catch (Exception ex)
                { }
                finally
                { }
        }
    }
}
namespace TesteWebService
{
    class SuporteTecnicoClientProxy : ClientBase<ISuporteTecnicoContract>, ISuporteTecnicoContract
    {
        public TPDV getCnpjParceiro(string _cnpj)
        {
            return this.Channel.getCnpjParceiro(_cnpj);
        }
    }
}
我的App.Config

<client>
    <endpoint adress="http://localhost:4600/SuporteTecnicoService.svc" binding="webHttpBinding" contract="V99SuporteTecnicoContracts.ISuporteTecnicoContract"
              behaviorConfiguration="WebBehavior">
    </endpoint>
  </client>
  <behaviors>
    <endpointBehaviors>
      <behavior name="WebBehavior">
        <webHttp />
      </behavior>
    </endpointBehaviors>
  </behaviors>


真正将生成上述异常的是什么。我的界面是另一个项目。类库项目。所以,我有两个项目。WCF项目(Web服务)和我的合同项目(POCO类和接口)。这是最后一个项目类库。

错误出现在
System.ServiceModel.Diagnostics.TraceUtility
;可能是因为您试图像调用SOAP服务一样调用RESTful服务而生成错误。您在配置中指定的客户端正在使用
webHttpBinding
——这是用于REST的。但是你试图像使用SOAP服务一样使用它。对于REST服务,您需要使用
HttpClient
或类似的工具。REST不使用代理。我正在阅读《Visual Studio 2010一步一步》(约翰·夏普-微软出版社)一书。我在这个例子中读了这本书。在这本书中,他要求使用Proxy。我没有这本书的权限,但我会仔细检查你所处的章节,以确保你没有忽略什么。我想不出任何方法可以使用SOAP客户端调用RESTful服务,但这并不意味着没有。我是WCF web服务的新手