从WCF到客户端的目标调用异常 [英] Target invocation exception from wcf to client

查看:119
本文介绍了从WCF到客户端的目标调用异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
我在WCF中使用silverlight.我在wcf中编写了业务逻辑,该逻辑将连接到数据库,并根据搜索条件获取所需的数据.当我将超过191条记录传递给客户端时
(即)

Hi all,
Im using silverlight with wcf. I have the business logic written in the wcf which will connect to database fetch the required data based on the search criteria. When I pass more than 191 records to the client
(i.e)

void svc_officeCon_gettotalattendhrsCompleted(object sender, gettotalattendhrsCompletedEventArgs e)


在上述事件(例如结果)中,我收到目标调用异常".
如果我通过少于190行即时通讯没有任何错误.我使用Ilist< myclass>存储数据并将其从服务器传递到客户端.我使用ms sql server 2008作为数据库. IList是否有限制?
可以有1个提示我有什么问题吗?
在此先感谢


这是我的网络配置.


In the above event(e.result) im getting "Target Invocation exception".
If i pass less than 190 rows im not getting any error. I use Ilist<myclass> to store and pass the data from server to client. And Im using ms sql server 2008 as my database. Is there any limit for IList?
Can any 1 suggest me what will be problem?
Thanks in advance


Here is my webconfig.

<?xml version="1.0"?>

<configuration>
  <connectionStrings>
    <add name="ConnectionString" connectionString="Data Source=testserver;Initial Catalog=Database;User ID=sa;Password=sa"/>
     </connectionStrings>

  <system.web>
    <compilation debug="true" targetFramework="4.0"/>
  <httpRuntime maxRequestLength="2097151" />
  </system.web>


  <system.serviceModel>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="true" />
    <bindings>
      <basicHttpBinding>         
        
        <binding name="PictureBinding" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647">
          <readerQuotas maxArrayLength="2000000" maxStringContentLength="2000000"/>        
        </binding>       
      </basicHttpBinding>
    </bindings>  
    <behaviors>
      <serviceBehaviors>
        <behavior name="Myproject.Web.ImageServiceBehaviour">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
        <behavior name="">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <services>
      <service behaviorConfiguration="Myproject.Web.ImageServiceBehaviour" name="Myproject.Web.wcfService">
        <endpoint address="" binding="basicHttpBinding" bindingConfiguration="PictureBinding" contract="Myproject.Web.IwcfService">
          <identity>
            <dns value="localhost"/>
          </identity>
        </endpoint>
      </service>
    </services>
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"></modules>
  </system.webServer>

</configuration>




以下是我的客户服务.




And below is my client Service.

<configuration>
    <system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="BasicHttpBinding_IwcfService" maxBufferSize="2147483647"
                    maxReceivedMessageSize="2147483647">
                    <security mode="None" />
                </binding>
            </basicHttpBinding>
          
        </bindings>
      
        <client>
            <endpoint address="http://localhost:2466/wcfService.svc"
                binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IwcfService"
                contract="ServiceReference.IwcfService" name="BasicHttpBinding_IwcfService" />
        </client>
    </system.serviceModel>
</configuration>



我犯错了吗?



Were im making mistake? Plz suggest?

推荐答案

选中此项.
http://forums.lhotka.net/forums/t/11235.aspx [ ^ ]

这就是我解决问题的方式

在客户端添加了行为配置.
Check this.
http://forums.lhotka.net/forums/t/11235.aspx[^]

and this is how i solved it

In client side added a behavior configuration.
<system.serviceModel>
        <behaviors>
            <endpointBehaviors>
                <behavior name="maxItems">
                    <dataContractSerializer maxItemsInObjectGraph="2147483646"/>
                </behavior>
            </endpointBehaviors>
        </behaviors>


并在端点中提供此行为配置

并在服务器端


and give this behavior configuration in End point

and in server side

<behavior name="ServiceBehavior">
         <dataContractSerializer maxItemsInObjectGraph="2147483647" />
         <serviceMetadata httpGetEnabled="true" />
         <serviceDebug includeExceptionDetailInFaults="true" />
       </behavior>



并将此行为添加到服务端点..试试这个



and added this behavior to the service endpoint.. try this


这篇关于从WCF到客户端的目标调用异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆