title: ReportViewer - "Unable to serialize the session state. in 'stateserver' and 'sqlserver' mode
body: <p>I am using VS2010 Report Viewer control in web application. The applications sessionstate mode is set to StateServer as follows</p>
  
  <pre><code>    &lt;sessionState timeout="30" mode="StateServer" stateConnectionString="tcpip=127.0.0.1:42424" sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes" cookieless="false" /&gt;
  </code></pre>
  
  <p>The reportviewer control is working fine on my devlopment machine but when the applicaiton is deployed onto server and when the reportviewer control page is loaded the following error is thrown.. All the other pages are working fine.</p>
  
  <p><strong>"Unable to serialize the session state. In 'StateServer' and 'SQLServer' mode, ASP.NET will serialize the session state objects, and as a result non-serializable objects or MarshalByRef objects are not permitted. The same restriction applies if similar serialization is done by the custom session state store in 'Custom' mode."</strong></p>
  
  <p>Can anyone please help, any idea will be of great help..</p>
  
  <p>Thanks in advance.</p>
  
  <hr>
  
  <pre><code>rptvw.ProcessingMode = ProcessingMode.Remote;
          rptvw.ServerReport.ReportServerUrl = new Uri("http://localhost:90/reportserver");
          rptvw.ServerReport.ReportPath = string.Format("/Reports/{0}", reportName);
  
          var param = new ReportParameter[4];
  
          param[0] = new ReportParameter("Parameter1", DropDownListCodes.SelectedValue));
          param[1] = new ReportParameter("Parameter2", DropDownListQuarters.SelectedValue));
          param[2] = new ReportParameter("Parameter3", DropDownListComparators.SelectedValue));
          param[3] = new ReportParameter("Parameter4", comptype);
  
          rptvw.ServerReport.SetParameters(param);
  
          rptvw.ServerReport.Refresh();
  </code></pre>