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

Instance variables are lost when using StateServer as session state provider

3 Answers 207 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
ilkruzn
Top achievements
Rank 1
ilkruzn asked on 24 Dec 2008, 04:30 PM
Hi all,

As you know, telerik reporting tool has some problems when the session state is persisted in ASP.NET StateServer.
Q3-SP2 (v2.9.8.1209) solved some issues about this, thank you, but I still have a problem and it is really weird.

I am creating a report object and setting the value of a private instance variable that I defined. The code snippet is;

/// <summary> 
    /// Summary description for Report1. 
    /// </summary> 
    [Serializable] 
    public partial class Report1 : Telerik.Reporting.Report 
    { 
        private int SomeVariable; 
        public Report1() 
        { 
            InitializeComponent(); 
        } 
        public Report1(int someVariable) 
            : this() 
        { 
            this.SomeVariable = someVariable; 
        } 
 
        private void Report1_NeedDataSource(object sender, System.EventArgs e) 
        { 
            (sender as Telerik.Reporting.Processing.Report).DataSource = 
                new SampleDataSourceItem[]{ 
                    new SampleDataSourceItem{ItemName="Item1", ItemValue=1}, 
                    new SampleDataSourceItem{ItemName="Item2", ItemValue=2}, 
                    new SampleDataSourceItem{ItemName="Item3", ItemValue=3}, 
                    new SampleDataSourceItem{ItemName="Item4", ItemValue=4}, 
                    new SampleDataSourceItem{ItemName="Item5", ItemValue=5} 
                }; 
        } 
 I am creating the report using the second constructor and pass the value for someVariable value. But when I debug the code at rendering time, i see that my instance variable does not hold the value I set. The report object is being created again using parameterless constructor by the rendering engine. This happens only when the sessionState is not "InProc".
This problem has come with SP2. We have lots of reports already designed and cannot find any workarounds. When will we have a SP that completely solves this session state problem???

--ilker

3 Answers, 1 is accepted

Sort by
0
Rossen Hristov
Telerik team
answered on 29 Dec 2008, 09:17 AM
Hello ilkruzn,

Thank you for contacting Telerik Support.

One of the differences between the InProc and SqlServer/State session modes is that when using the first one the instance of the report definition is kept in memory while in the second mode it should be serialized and deserialized. When deserializing the report is created through reflection by calling the report's default constructor (through Activator.CreateInstance()). In this way any methods which configure the report definition after it has been created could not be reapplied, so everything should be configured only in the report's default constructor.


The fix is not trivial and it requires major changes to some of the core parts of our Reporting solution. We have already started working on this issue. As a temporary workaround, we believe that you might get this working by keeping your "parameter" in Session and access it in the report's default constructor through the HttpContext.Current.Session.

Sorry for the temporary inconvenience.


Best wishes,
Ross
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
ilkruzn
Top achievements
Rank 1
answered on 29 Dec 2008, 11:43 AM
Hi Ross,

I don't believe that serialization/deserialization causes to loose the state of an object completely. You can try it by creating any Serializable object and serializing then deserializing it using BinaryFormatter. You will see that all of the variables are there after deserialization. This situation remains the same for serializing/deserialization the ASP.NET session state. 

Anyway, we have lots of reports already designed. And for one of our customers, we should not use InProc sessions. Even if we could applying the workaround you provided will require some time for us. It will be really helpful if you provide an estimate time for a fix to this problem.

note: We designed reports in a separate class library and it is not so cool to use HttpSessionState and System.Web reference in that assembly, cause we may use it in a windows application some time in the future.

Thanx for all your help

--ilker
0
Rossen Hristov
Telerik team
answered on 29 Dec 2008, 12:02 PM
Hello ilkruzn,

At the time being we cannot provide a specific time frame for these improvements. Once we have a clearer view, we will immediately update our product road-map. Thank you for your understanding.

Greetings,
Ross
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
General Discussions
Asked by
ilkruzn
Top achievements
Rank 1
Answers by
Rossen Hristov
Telerik team
ilkruzn
Top achievements
Rank 1
Share this question
or