This is a migrated thread and some comments may be shown as answers.

Unable to serialize the session state in PivotGrid

4 Answers 99 Views
PivotGrid
This is a migrated thread and some comments may be shown as answers.
Francis
Top achievements
Rank 1
Francis asked on 25 May 2015, 01:09 AM

We are using RadPivotGrid and was working fine until we change the sessionState to SQLServer. And now getting the error:

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.

 Stack Trace:

 [SerializationException: Type 'Telerik.Web.UI.PivotGrid.Core.ViewModels.PivotViewModel' in Assembly 'Telerik.Web.UI, Version=2015.1.401.45, Culture=neutral, PublicKeyToken=121fae78165ba3d4' is not marked as serializable.]
System.Runtime.Serialization.FormatterServices.InternalGetSerializableMembers(RuntimeType type) +14052545
System.Runtime.Serialization.FormatterServices.GetSerializableMembers(Type type, StreamingContext context) +408
System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitMemberInfo() +420
System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitSerialize(Object obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, ObjectWriter objectWriter, SerializationBinder binder) +532
System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.Serialize(Object obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, ObjectWriter objectWriter, SerializationBinder binder) +270
System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Serialize(Object graph, Header[] inHeaders, __BinaryWriter serWriter, Boolean fCheck) +814
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(Stream serializationStream, Object graph, Header[] headers, Boolean fCheck) +322
System.Web.Util.AltSerialization.WriteValueToStream(Object value, BinaryWriter writer) +1487

[HttpException (0x80004005): 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.]
System.Web.Util.AltSerialization.WriteValueToStream(Object value, BinaryWriter writer) +2252815
System.Web.SessionState.SessionStateItemCollection.WriteValueToStreamWithAssert(Object value, BinaryWriter writer) +49
System.Web.SessionState.SessionStateItemCollection.Serialize(BinaryWriter writer) +729
System.Web.SessionState.SessionStateUtility.Serialize(SessionStateStoreData item, Stream stream) +336
System.Web.SessionState.SessionStateUtility.SerializeStoreData(SessionStateStoreData item, Int32 initialStreamSize, Byte[]& buf, Int32& length, Boolean compressionEnabled) +99
System.Web.SessionState.SqlSessionStateStore.SetAndReleaseItemExclusive(HttpContext context, String id, SessionStateStoreData item, Object lockId, Boolean newItem) +3538988
System.Web.SessionState.SessionStateModule.OnReleaseState(Object source, EventArgs eventArgs) +1021
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +92
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +165

 

4 Answers, 1 is accepted

Sort by
0
Vasil
Telerik team
answered on 27 May 2015, 11:01 AM
Hello Francis,

Based on the provided information we can not determinate why you are facing this problem.

Indeed the Telerik.Web.UI.PivotGrid.Core.ViewModels.PivotViewModel is not marked as Serializable, by design, and I am not sure why the framework is trying to serialize it in your case.

Could you you share more details on how you are using the PivotGrid in your page?


Regards,
Vasil
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Francis
Top achievements
Rank 1
answered on 27 May 2015, 10:08 PM

Hi Vasil,

 

Thanks for your reply. So the radpivot is in a usercontrol and we are just using a sqldatasource with a stored procedure as datasource: 

    

<telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPaneluExpenses" runat="server">
</telerik:RadAjaxLoadingPanel>
<telerik:RadAjaxPanel runat="server" ID="ajuExpenses" LoadingPanelID="RadAjaxLoadingPaneluExpenses" ClientEvents-OnRequestStart="onRequestStart">
    <telerik:RadPivotGrid ID="RadPivotGrid1" runat="server" AllowSorting="True" DataSourceID="SqlPermitExpenses" EmptyValue="No expenses to show" EnableCaching="True" EnableToolTips="True" Skin="Metro" FilterHeaderZoneText="">
        <PagerStyle ChangePageSizeButtonToolTip="Change Page Size" PageSizeControlType="RadComboBox"></PagerStyle>
        <ExportSettings Excel-Format="Xlsx" OpenInNewWindow="true" UseItemStyles="true">
            <Excel Format="Xlsx" />
        </ExportSettings>
        <OlapSettings>
        </OlapSettings>
        <Fields>
            <telerik:PivotGridRowField DataField="PermitNumber" UniqueName="PermitNumber" Caption="Permit Number" />
            <telerik:PivotGridColumnField DataField="SpendDate" GroupInterval="Year" UniqueName="BudgetDatey" Caption="Year" />
            <telerik:PivotGridColumnField DataField="SpendDate" GroupInterval="Quarter" UniqueName="BudgetDateq" Caption="Quarter" />
            <telerik:PivotGridColumnField DataField="SpendDate" GroupInterval="Month" UniqueName="BudgetDatem" Caption="Month" />
            <telerik:PivotGridAggregateField DataField="ExpenseValueExcTax" Aggregate="Sum" UniqueName="ExpenseValueExcTax" Caption="Cost" DataFormatString="{0:C}">
                <TotalFormat Axis="Rows" Level="0" SortOrder="Ascending" TotalFunction="NoCalculation" />
            </telerik:PivotGridAggregateField>
        </Fields>
        <ConfigurationPanelSettings DefaultDeferedLayoutUpdate="True" EnableDragDrop="False" />
    </telerik:RadPivotGrid>
    <asp:SqlDataSource ID="SqlPermitExpenses" runat="server" ConnectionString="<%$ ConnectionStrings:SiteSqlServer %>" SelectCommand="SomeStoredProcedure" SelectCommandType="StoredProcedure">
        <SelectParameters>
            <asp:SessionParameter DefaultValue="0" Name="TenantID" SessionField="TenantID" Type="Int32" />
        </SelectParameters>
 
    </asp:SqlDataSource>
    <script type="text/javascript">
        function onRequestStart(sender, args) {
            if (args.get_eventTarget().indexOf("ExportToExcelButton") >= 0 ||
                args.get_eventTarget().indexOf("ExportToWordButton") >= 0 ||
                args.get_eventTarget().indexOf("ExportToPdfButton") >= 0 ||
                args.get_eventTarget().indexOf("ExportToCsvButton") >= 0) {
                args.set_enableAjax(false);
            }
        }
    </script>
 
</telerik:RadAjaxPanel>

 

and in code behind:

 

protected void Page_Load(object sender, EventArgs e)
{
    if (!IsPostBack)
    {
        RadPivotGrid1.OlapSettings.XmlaConnectionSettings.Encoding = System.Text.Encoding.UTF8;
    }
}

 

Cheers!

Francis

 

0
Accepted
Vasil
Telerik team
answered on 01 Jun 2015, 08:25 AM
Hello Francis,

Currently I would suggest you to set EnableCaching="False" for your PivotGrid in order to resolve the problem. We will investigate further the issue to see why the caching works correctly with InProc SessionState but not in SQLServer mode.

Regards,
Vasil
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Francis
Top achievements
Rank 1
answered on 02 Jun 2015, 04:43 AM

Thanks so much Vasil, that works for me. 

 

Cheers!

Francis

Tags
PivotGrid
Asked by
Francis
Top achievements
Rank 1
Answers by
Vasil
Telerik team
Francis
Top achievements
Rank 1
Share this question
or