我新建了1个wcf项目,和一个web应用程序,web应用程序调用wcf没任何错误我现在想把调用那部分程序单独脱离出来建个类库访问的时候就出错,出
在 ServiceModel 客户端配置部分中,找不到引用协定“ServiceReference1.IUpLoadService”的默认终结点元素。这可能是因为未找到应用程序的配置文件,或者是因为客户端元素中找不到与此协定匹配的终结点元素。 这错误调用的方法都是同1个,只是第一个是在web应用程序里调用,出错的是在类库里调用
有人知道如何在类库中访问wcf

解决方案 »

  1.   

    app.config文件内容是<?xml version="1.0" encoding="utf-8" ?>
    <configuration>
      <system.serviceModel>
        <bindings>
          <basicHttpBinding>
            <binding name="BasicHttpBinding_IUpLoadService" closeTimeout="00:01:00"
             openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:10:00"
             allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
             maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="9223372036854775807"
             messageEncoding="Mtom" textEncoding="utf-8" transferMode="Streamed"
             useDefaultWebProxy="true">
              <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
               maxBytesPerRead="4096" maxNameTableCharCount="16384" />
              <security mode="None">
                <transport clientCredentialType="None" proxyCredentialType="None"
                 realm="" />
                <message clientCredentialType="UserName" algorithmSuite="Default" />
              </security>
            </binding>
          </basicHttpBinding>
        </bindings>
        <client>
          <endpoint address="http://www.ddddddd.com/UpLoadService.svc"
           binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IUpLoadService"
           contract="UpLoadService.IUpLoadService" name="BasicHttpBinding_IUpLoadService" />
        </client>
      </system.serviceModel>
    </configuration>
      

  2.   

    还没有接触过wfc,不过我想这个是最基础的内容阿,你找本书里面都应该有讲解的阿
      

  3.   

    这个配置文件里的命名空间,是否不对.
    或者,你可以试试从解决方案中发现WCF服务引用的方法来调用.
      

  4.   

    在wcf 中可以引用System.Web.HttpContext.Current.Server.MapPath(request.SavePath)马  ,为什么一直都提示我未将对象引用设置到对象的实例。System.Web空间都引用了
      

  5.   

    没人这样做过吗,都是直接在web页面直接引用的马
      

  6.   

    不管是在DLL中还是exe中引用WCF Service,生成的配置文件默认为生成的Dll或者exe文件名.config,而在别的地方引用这个Dll或者exe,读取的配置文件却是这个dll或exe名字.config,所以造成了这个问题。
      

  7.   

    如果把WCF的客户端单独拿出来作为类库的话,WCF客户端的类库会有一个app.config文件,需要把这个文件中的以下部分
    <system.serviceModel>
    省略
    </system.serviceModel>复制然后粘贴到主程序(Main函数所在工程)的app.config文件中的<configuration></configuration>中。
      

  8.   

    wcf restful模式,实现http调用
    具体可以
    参考www.cnblogs.com/mail-ricklee中的FortuneBase