
Nate Pinchot
Top achievements
Rank 1
Nate Pinchot
asked on 13 Mar 2009, 09:27 PM
Getting this error trying to display a report with the Q1 2009 Web ReportViewer control.
This was a working project that was upgraded to Q1 2009 and I have made no code changes other than to adjust for changed properties. I should note that this report is displayed inside of a radWindow (if that makes any difference I don't know). I am indeed using SQL Server for the session state. Please help, this was working perfectly until the Q1 2009 upgrade.
Nate
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.
This was a working project that was upgraded to Q1 2009 and I have made no code changes other than to adjust for changed properties. I should note that this report is displayed inside of a radWindow (if that makes any difference I don't know). I am indeed using SQL Server for the session state. Please help, this was working perfectly until the Q1 2009 upgrade.
Nate
3 Answers, 1 is accepted
0
Hi Nate Pinchot,
The most likely reason for the problem is that the object which you use for the report's data source is not serializable and thus cannot be put in an SQLServer session. With the new release of the Reporting tool (Q1 2009) we have introduced a new data engine in order to greatly improve the processing performance and to add support for the CrossTab, Table and List report items. As a result the data source is no longer automatically resolved to a data set and rather the raw data objects are used. This, however, requires some additional steps if the data source should be stored in an SQLServer or StateServer session. To make it work you have to make your data source serializable, transform it to a DataSet or Table, or use the NeedDataSource event of the report.
Hope this helps. Let me know if you have any other questions.
Kind regards,
Chavdar
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
The most likely reason for the problem is that the object which you use for the report's data source is not serializable and thus cannot be put in an SQLServer session. With the new release of the Reporting tool (Q1 2009) we have introduced a new data engine in order to greatly improve the processing performance and to add support for the CrossTab, Table and List report items. As a result the data source is no longer automatically resolved to a data set and rather the raw data objects are used. This, however, requires some additional steps if the data source should be stored in an SQLServer or StateServer session. To make it work you have to make your data source serializable, transform it to a DataSet or Table, or use the NeedDataSource event of the report.
Hope this helps. Let me know if you have any other questions.
Kind regards,
Chavdar
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0

Nate Pinchot
Top achievements
Rank 1
answered on 16 Mar 2009, 03:09 PM
How would you suggest using LINQ to populate the data for the report?
Previously I was using the following code to populate the report data using LINQ:
It is obviously not an easy task to take an anonymous data type and convert it into a DataTable.
I am very disappointed that you have taken a step back and are not allowing support for anonymous data types to populate the report data.
The ReportViewer does not have a NeedDataSource event and I am not sure how the NeedDataSource event of the report itself will help me populate the data at run-time through codebehind of the webpage? Keep in mind the report itself is compiled separately and so it does not have access to the database layer.
I'm really not sure where to go from here. Seems like the Q1 2009 version of the reporting has just made life entirely more complicated than it needs to be.
Previously I was using the following code to populate the report data using LINQ:
if (Request.QueryString["QuoteId"] == null) |
{ |
rvQuote.Visible = false; |
return; |
} |
Page.Title = "Printing Quote # " + Request.QueryString["QuoteId"].ToString(); |
long intQuoteId; |
long.TryParse(Request.QueryString["QuoteId"].ToString(), out intQuoteId); |
// create database connection object |
var database = new WorkOrderSystemDataContext(Constants.DatabaseConnectionString); |
var quote = (from q in database.Quotes |
join li in database.QuoteLineItems on q.QuoteId equals li.QuoteId |
join ba in database.Addresses on q.BillingAddressId equals ba.AddressId |
join sa in database.Addresses on q.ShippingAddressId equals sa.AddressId |
join con in database.Contacts on q.ContactId equals con.ContactId |
join c in database.Companies on q.CompanyId equals c.CompanyId |
join sp in database.SalesPersons on q.SalesPersonId equals sp.SalesPersonId |
join csp in database.SalesPersons on c.SalesPersonId equals csp.SalesPersonId |
join st in database.SalesTaxes on ba.SalesTaxId equals st.SalesTaxId |
where q.QuoteId == intQuoteId && li.Active == true |
select new |
{ |
q.QuoteId, |
q.Description, |
PaymentTerms = q.PaymentTerms.DisplayName, |
BillingAddress1 = ba.Address1, |
BillingAddress2 = ba.Address2, |
BillingAddress3 = ba.Address3, |
BillingCity = ba.City, |
BillingState = ba.State, |
BillingZipCode = ba.ZipCode, |
ShippingAddress1 = sa.Address1, |
ShippingAddress2 = sa.Address2, |
ShippingAddress3 = sa.Address3, |
ShippingCity = sa.City, |
ShippingState = sa.State, |
ShippingZipCode = sa.ZipCode, |
con.FirstName, |
con.LastName, |
con.EmailAddress, |
LineItemQuantity = li.Quantity, |
LineItemPrice = li.Price, |
LineItemDescription = li.Description, |
LineItemItemNumber = li.ItemNumber, |
CompanyName = c.DisplayName, |
c.PhoneNumber, |
c.FaxNumber, |
c.AccountNumber, |
st.Tax, |
SalesPerson = (sp.SalesPersonId != Constants.UnassignedSalesPersonId ? sp.DisplayName : csp.DisplayName) |
}).ToList(); |
rvQuote.Report.Reports.First().DataSource = quote; |
rvQuote.DataBind(); |
It is obviously not an easy task to take an anonymous data type and convert it into a DataTable.
I am very disappointed that you have taken a step back and are not allowing support for anonymous data types to populate the report data.
The ReportViewer does not have a NeedDataSource event and I am not sure how the NeedDataSource event of the report itself will help me populate the data at run-time through codebehind of the webpage? Keep in mind the report itself is compiled separately and so it does not have access to the database layer.
I'm really not sure where to go from here. Seems like the Q1 2009 version of the reporting has just made life entirely more complicated than it needs to be.
0
Hello Nate Pinchot,
You can create an extension method which converts anonymous type result to a DataTable. For example:
public static class VarToTable
{
public static DataTable ToADOTable<T>(this IEnumerable<T> varlist)
{
DataTable dtReturn = new DataTable();
// Could add a check to verify that there is an element 0
T TopRec = varlist.ElementAt(0);
// Use reflection to get property names, to create table
// column names
PropertyInfo[] oProps =
((Type)TopRec.GetType()).GetProperties();
foreach (PropertyInfo pi in oProps)
dtReturn.Columns.Add(
pi.Name, pi.PropertyType);
foreach (T rec in varlist)
{
DataRow dr = dtReturn.NewRow();
foreach (PropertyInfo pi in oProps)
dr[pi.Name] = pi.GetValue(rec, null);
dtReturn.Rows.Add(dr);
}
return (dtReturn);
}
}
It can be used in the same way as the ToList() method in your code:
string[] names = { "John", "Peter", "Joe", "Patrick", "Donald", "Eric" };
var quote = (from name in names
where name.Length < 5
select new { Name = name }).ToADOTable();
Here you can find the original article describing the approach.
Best wishes,
Chavdar
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
You can create an extension method which converts anonymous type result to a DataTable. For example:
public static class VarToTable
{
public static DataTable ToADOTable<T>(this IEnumerable<T> varlist)
{
DataTable dtReturn = new DataTable();
// Could add a check to verify that there is an element 0
T TopRec = varlist.ElementAt(0);
// Use reflection to get property names, to create table
// column names
PropertyInfo[] oProps =
((Type)TopRec.GetType()).GetProperties();
foreach (PropertyInfo pi in oProps)
dtReturn.Columns.Add(
pi.Name, pi.PropertyType);
foreach (T rec in varlist)
{
DataRow dr = dtReturn.NewRow();
foreach (PropertyInfo pi in oProps)
dr[pi.Name] = pi.GetValue(rec, null);
dtReturn.Rows.Add(dr);
}
return (dtReturn);
}
}
It can be used in the same way as the ToList() method in your code:
string[] names = { "John", "Peter", "Joe", "Patrick", "Donald", "Eric" };
var quote = (from name in names
where name.Length < 5
select new { Name = name }).ToADOTable();
Here you can find the original article describing the approach.
Best wishes,
Chavdar
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.