Click here to Skip to main content
15,886,063 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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)

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.
C#
<?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?
Posted
Updated 20-Sep-12 21:11pm
v3
Comments
Santhosh Kumar Jayaraman 21-Sep-12 3:34am    
have you tried my solution by adding dataContractSerializer?
Saranya811 21-Sep-12 3:51am    
I added to web.config. But im not able to add in clientconfig. It gives me "The element system.serviceModel has invalid child element behviors".
Santhosh Kumar Jayaraman 21-Sep-12 4:22am    
thats because WCF concept of behaviors doesn't exist in the Silverlight 4
Santhosh Kumar Jayaraman 21-Sep-12 4:24am    
And are you still getting the error?
Saranya811 21-Sep-12 4:31am    
Thank you so much for the solution. I have added the "datacontractserializer maxitemsinobjectgraph="2147483647" to my web config which was missing. Now it executes perfect. I have not changed any code in my clientconfig. Thank you once again.

1 solution

Check this.
http://forums.lhotka.net/forums/t/11235.aspx[^]

and this is how i solved it

In client side added a behavior configuration.
XML
<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
XML
<behavior name="ServiceBehavior">
         <dataContractSerializer maxItemsInObjectGraph="2147483647" />
         <serviceMetadata httpGetEnabled="true" />
         <serviceDebug includeExceptionDetailInFaults="true" />
       </behavior>


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

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900