locked
winform control与WebService的通信问题 RRS feed

  • 问题

  • 我有一个WebService,VS2008新建的默认的那种,里面有个HelloWorld方法,然后,我在一个WindowsFormApplication的项目里添加了对这个服务的引用,然后下面的代码是可以执行的。

                ServiceReference1.Service1SoapClient s = new WindowsFormsApplication1.ServiceReference1.Service1SoapClient();
                MessageBox.Show(s.HelloWorld());
    

    但是此时我将服务添加到一个WindowsFormControlLibrary项目的时候,相同的代码却报出下面的错误:

    在 ServiceModel 客户端配置部分中,找不到引用协定“ServiceReference1.Service1Soap”的默认终结点元素。这可能是因为未找到应用程序的配置文件,或者是因为客户端元素中找不到与此协定匹配的终结点元素。

    麻烦问一下,为何会出现如此错误?应该如何解决?谢谢。

    2011年9月15日 0:11

答案

  • exe文件的config里面要加endpoint的配置

    The following is signature, not part of post
    Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.
    Visual C++ MVP
    2011年9月15日 1:39

全部回复

  • exe文件的config里面要加endpoint的配置

    The following is signature, not part of post
    Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.
    Visual C++ MVP
    2011年9月15日 1:39
  • 如果你的是在dll中添加了webservice的引用,exe中调用了这个dll的话,可以在exe中再添加webservice的引用。
    2012年2月4日 8:01