locked
Session State Caching and the ReportViewer Control

    Question

  • I'm using the ReportViewer control included with Visual Studio 2010 on an ASP.NET page. The control has its processing mode set to Local, which means the control needs to save state in the session, which becomes a problem once I deploy to Azure with multiple instances for the web role containing the ASP.NET page.

    I've successfully been able to use the TableStorageSessionStateProvider in the ASPProviders project in the Windows Azure Training Kit to provide out-of-process session state in Azure, but now I'm trying to use the AppFabric Caching CTP instead. I've got it all configured in my web.config (using the Microsoft.Web.DistributedCache.DistributedCacheSessionStateStoreProvider), but when the ReportViewer control attempts to access session state, I get the exception listed below. My guess is that the AppFabric caching session state provider is serializing/deserializing the session in such a way that it doesn't like what the ReportViewer control is storing, unlike the TableStorageSessionStateProvider or the normal ASP.NET InProc sessions.

    I don't have control over either the ReportViewer or the Microsoft.Web.DistributedCache.DistributedCacheSessionStateStoreProvider, so I'm not sure if this is something that can be addressed on the AppFabric side or not.

    Server Error in '/' Application.

     

    Type 'Microsoft.Reporting.WebForms.SyncList`1[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]' is an invalid collection type since it does not have a default constructor.

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

     

    Exception Details: System.Runtime.Serialization.InvalidDataContractException: Type 'Microsoft.Reporting.WebForms.SyncList`1[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]' is an invalid collection type since it does not have a default constructor.

     

    Source Error:

     

     

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

    Stack Trace:

     

     


    [InvalidDataContractException: Type 'Microsoft.Reporting.WebForms.SyncList`1[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]' is an invalid collection type since it does not have a default constructor.]
       System.Runtime.Serialization.CollectionDataContract.GetValidContract(SerializationMode mode) +2370517
       System.Runtime.Serialization.DataContract.GetDataContract(Int32 id, RuntimeTypeHandle typeHandle, SerializationMode mode) +121
       System.Runtime.Serialization.ClassDataContractCriticalHelper..ctor(Type type) +740
       System.Runtime.Serialization.CollectionDataContract.GetSharedTypeContract(Type type) +153
       System.Runtime.Serialization.CollectionDataContract.HandleIfInvalidCollection(Type type, Boolean tryCreate, Boolean hasCollectionDataContract, Boolean createContractWithException, String message, String param, DataContract& dataContract) +2386592
       System.Runtime.Serialization.CollectionDataContract.IsCollectionOrTryCreate(Type type, Boolean tryCreate, DataContract& dataContract, Type& itemType, Boolean constructorRequired) +2384828
       System.Runtime.Serialization.DataContractCriticalHelper.CreateDataContract(Int32 id, RuntimeTypeHandle typeHandle, Type type) +641
       System.Runtime.Serialization.DataContract.GetDataContract(Int32 id, RuntimeTypeHandle typeHandle, SerializationMode mode) +105
       System.Runtime.Serialization.XmlObjectSerializerWriteContextComplex.GetDataContract(RuntimeTypeHandle typeHandle, Type type) +195
       System.Runtime.Serialization.XmlObjectSerializerWriteContext.SerializeWithXsiType(XmlWriterDelegator xmlWriter, Object obj, RuntimeTypeHandle objectTypeHandle, Type objectType, Int32 declaredTypeID, RuntimeTypeHandle declaredTypeHandle, Type declaredType) +548
       System.Runtime.Serialization.XmlObjectSerializerWriteContext.InternalSerialize(XmlWriterDelegator xmlWriter, Object obj, Boolean isDeclaredType, Boolean writeXsiType, Int32 declaredTypeID, RuntimeTypeHandle declaredTypeHandle) +2384331
       System.Runtime.Serialization.XmlObjectSerializerWriteContext.InternalSerializeReference(XmlWriterDelegator xmlWriter, Object obj, Boolean isDeclaredType, Boolean writeXsiType, Int32 declaredTypeID, RuntimeTypeHandle declaredTypeHandle) +111
       System.Runtime.Serialization.XmlObjectSerializerWriteContext.WriteSerializationInfo(XmlWriterDelegator xmlWriter, Type objType, SerializationInfo serInfo) +772
       System.Runtime.Serialization.XmlObjectSerializerWriteContext.WriteISerializable(XmlWriterDelegator xmlWriter, ISerializable obj) +206
       System.Runtime.Serialization.ClassDataContract.WriteXmlValue(XmlWriterDelegator xmlWriter, Object obj, XmlObjectSerializerWriteContext context) +49
       System.Runtime.Serialization.XmlObjectSerializerWriteContext.InternalSerialize(XmlWriterDelegator xmlWriter, Object obj, Boolean isDeclaredType, Boolean writeXsiType, Int32 declaredTypeID, RuntimeTypeHandle declaredTypeHandle) +109
       System.Runtime.Serialization.XmlObjectSerializerWriteContext.InternalSerializeReference(XmlWriterDelegator xmlWriter, Object obj, Boolean isDeclaredType, Boolean writeXsiType, Int32 declaredTypeID, RuntimeTypeHandle declaredTypeHandle) +111
       WriteServerModeSessionToXml(XmlWriterDelegator , Object , XmlObjectSerializerWriteContext , ClassDataContract ) +542
       System.Runtime.Serialization.ClassDataContract.WriteXmlValue(XmlWriterDelegator xmlWriter, Object obj, XmlObjectSerializerWriteContext context) +49
       System.Runtime.Serialization.XmlObjectSerializerWriteContext.InternalSerialize(XmlWriterDelegator xmlWriter, Object obj, Boolean isDeclaredType, Boolean writeXsiType, Int32 declaredTypeID, RuntimeTypeHandle declaredTypeHandle) +109
       System.Runtime.Serialization.XmlObjectSerializerWriteContext.InternalSerializeReference(XmlWriterDelegator xmlWriter, Object obj, Boolean isDeclaredType, Boolean writeXsiType, Int32 declaredTypeID, RuntimeTypeHandle declaredTypeHandle) +111
       WriteReportInfoToXml(XmlWriterDelegator , Object , XmlObjectSerializerWriteContext , ClassDataContract ) +479
       System.Runtime.Serialization.ClassDataContract.WriteXmlValue(XmlWriterDelegator xmlWriter, Object obj, XmlObjectSerializerWriteContext context) +49
       System.Runtime.Serialization.XmlObjectSerializerWriteContext.InternalSerialize(XmlWriterDelegator xmlWriter, Object obj, Boolean isDeclaredType, Boolean writeXsiType, Int32 declaredTypeID, RuntimeTypeHandle declaredTypeHandle) +109
       System.Runtime.Serialization.XmlObjectSerializerWriteContext.InternalSerializeReference(XmlWriterDelegator xmlWriter, Object obj, Boolean isDeclaredType, Boolean writeXsiType, Int32 declaredTypeID, RuntimeTypeHandle declaredTypeHandle) +111
       WriteArrayOfReportInfoToXml(XmlWriterDelegator , Object , XmlObjectSerializerWriteContext , CollectionDataContract ) +297
       System.Runtime.Serialization.CollectionDataContract.WriteXmlValue(XmlWriterDelegator xmlWriter, Object obj, XmlObjectSerializerWriteContext context) +65
       System.Runtime.Serialization.XmlObjectSerializerWriteContext.InternalSerialize(XmlWriterDelegator xmlWriter, Object obj, Boolean isDeclaredType, Boolean writeXsiType, Int32 declaredTypeID, RuntimeTypeHandle declaredTypeHandle) +109
       System.Runtime.Serialization.XmlObjectSerializerWriteContext.InternalSerializeReference(XmlWriterDelegator xmlWriter, Object obj, Boolean isDeclaredType, Boolean writeXsiType, Int32 declaredTypeID, RuntimeTypeHandle declaredTypeHandle) +111
       WriteReportHierarchyToXml(XmlWriterDelegator , Object , XmlObjectSerializerWriteContext , ClassDataContract ) +343
       System.Runtime.Serialization.ClassDataContract.WriteXmlValue(XmlWriterDelegator xmlWriter, Object obj, XmlObjectSerializerWriteContext context) +49
       System.Runtime.Serialization.NetDataContractSerializer.InternalWriteObjectContent(XmlWriterDelegator writer, Object graph, DataContract contract, Hashtable surrogateDataContracts) +289
       System.Runtime.Serialization.NetDataContractSerializer.InternalWriteObject(XmlWriterDelegator writer, Object graph) +185
       System.Runtime.Serialization.XmlObjectSerializer.WriteObjectHandleExceptions(XmlWriterDelegator writer, Object graph, DataContractResolver dataContractResolver) +662
       System.Runtime.Serialization.XmlObjectSerializer.WriteObject(XmlDictionaryWriter writer, Object graph) +133
       Microsoft.ApplicationServer.Caching.Utility.Serialize(Object obj, Object context) +629
       Microsoft.ApplicationServer.Caching.SimpleClient.SendMsgAndWait(RequestBody reqMsg) +146
       Microsoft.ApplicationServer.Caching.DataCache.SendReceive(RequestBody reqMsg) +160
       Microsoft.ApplicationServer.Caching.DataCache.InternalPut(String key, Object value, DataCacheItemVersion oldVersion, TimeSpan timeout, DataCacheTag[] tags, String region) +405
       Microsoft.ApplicationServer.Caching.DataCache.Put(String key, Object value, TimeSpan timeout) +94
       Microsoft.Web.DistributedCache.<>c__DisplayClass2e`1.<PerformCacheOperation>b__2d() +19
       Microsoft.Web.DistributedCache.DataCacheRetryWrapper.PerformCacheOperation(Action action) +66
       Microsoft.Web.DistributedCache.DataCacheForwarderBase.PerformCacheOperation(Func`1 func) +167
       Microsoft.Web.DistributedCache.DataCacheForwarderBase.Put(String key, Object value, TimeSpan timeout) +145
       Microsoft.Web.DistributedCache.<>c__DisplayClass2e`1.<PerformCacheOperation>b__2d() +19
       Microsoft.Web.DistributedCache.DataCacheForwarderBase.PerformCacheOperation(Func`1 func) +167
       Microsoft.Web.DistributedCache.DataCacheForwarderBase.Put(String key, Object value, TimeSpan timeout) +145
       System.Threading.Tasks.Task.Execute() +130

    [AggregateException: One or more errors occurred.]
       System.Threading.Tasks.Task.WaitAll(Task[] tasks, Int32 millisecondsTimeout, CancellationToken cancellationToken) +1738
       System.Threading.Tasks.Task.WaitAll(Task[] tasks, Int32 millisecondsTimeout) +84
       System.Threading.Tasks.Task.WaitAll(Task[] tasks) +39
       Microsoft.Web.DistributedCache.GranularSessionStoreProvider.SetAndReleaseItemExclusiveImpl(HttpContextBase context, String id, SessionStateStoreData item, Object lockId, Boolean newItem) +3317
       Microsoft.Web.DistributedCache.<>c__DisplayClass25.<SetAndReleaseItemExclusive>b__24() +47
       Microsoft.Web.DistributedCache.GranularSessionStoreProvider.ExecNonAbortable(Action a) +33
       System.Web.SessionState.SessionStateModule.OnReleaseState(Object source, EventArgs eventArgs) +929
       System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +80
       System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +266


    Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1

    Thursday, January 20, 2011 1:49 PM

Answers

  • Hi Richard,

    Wanted to follow up on Karan's post earlier. This is a bug and we will consider it for fixing in a future release. As Jaime mentions earlier , the lack of default constructor on the object being cached is causing this issue and unfortunately no workarounds exist since the object is not in your control.

    Thanks for reporting this issue and we will consider it for our next release.

    Nithya

     

    • Marked as answer by RichardIw Thursday, January 27, 2011 4:02 PM
    Thursday, January 27, 2011 11:43 AM

All replies

  • Hi Richard,

    Thanks for the fedback - while we investigate this, please can you check if you are able to successfully use the Cache session provider to store the session state for a regular ASP.NET page as part of this Azure app? Once we have the web.config or other config issues out of the way, we'll work with the ReportViewer team to narrow this down.

    Thanks for trying this out!
    Karan


    This information is provided as-is.
    Monday, January 24, 2011 10:43 PM
  • Your guess is exactly right,

    AF needs to have the capability to deserialize and serialize the object but unlike other "simpler" objects, we need to fulfill a few requirements before this can be done. In a sense, not all collections are directly supported. In your case it is because a default constructor does not exist. The following article goes into great detail on how to go about it - http://msdn.microsoft.com/en-us/library/aa347850.aspx

    Hope this helps,

    -Jaime.


    -Jaime.
    Monday, January 24, 2011 10:50 PM
    Moderator
  • Karan,

    I can confirm I was able to successfully deploy a 2-instance web role to Azure and use ASP.NET session state on a normal web form.

    For reference, my web.config file was configured as follows:

    		<sessionState mode="Custom" customProvider="AppFabricCacheSessionStoreProvider">
    <providers>
    <clear/>
    <add name="AppFabricCacheSessionStoreProvider"
     type="Microsoft.Web.DistributedCache.DistributedCacheSessionStateStoreProvider, Microsoft.Web.DistributedCache"
     cacheName="default"
     applicationName="MyApp"
     useBlobMode="true" />
    </providers>
    </sessionState>

    and I have a dataCacheClient section earlier in the web.config as well. I was able to store a string as well as custom class objects, both with and without an explicit constructor, in the session and retrieve them as well.

    Thanks,

    Richard

    Tuesday, January 25, 2011 1:10 AM
  • Hi Richard,

    Thanks for the update! In working with the ASP.NET team on the session state provider our early investigation tells us that we are hitting some issue with the use of NetDataContractSerializer because of which the complex data type used by the ReportViewer is not getting serialized correctly. We'll continue this investigation and post back our findings and/or a solution soon.

    Thanks again for reporting this!
    Karan


    This information is provided as-is.
    Thursday, January 27, 2011 9:16 AM
  • Hi Richard,

    Wanted to follow up on Karan's post earlier. This is a bug and we will consider it for fixing in a future release. As Jaime mentions earlier , the lack of default constructor on the object being cached is causing this issue and unfortunately no workarounds exist since the object is not in your control.

    Thanks for reporting this issue and we will consider it for our next release.

    Nithya

     

    • Marked as answer by RichardIw Thursday, January 27, 2011 4:02 PM
    Thursday, January 27, 2011 11:43 AM
  • Thanks everyone for the investigation. It would be really useful to be able to get this fixed in a future release; right now it's looking like I'll have to have a worker role running in Azure to maintain and clean up whatever session solution I end up using to get around this issue (be it in SQL or in table storage). It would be preferable to be able to use the AppFabric caching once it's released. Thanks again,

    Richard

    Thursday, January 27, 2011 4:05 PM
  • Hey - I'm having exactly the same issue - does anyone know when this will be repaired. This effectively prevents us from deploying our app to Azure in a production environment.

    Thanks!

    Thursday, May 05, 2011 5:56 PM
  • Yep same problem here.

    Does anyone have any idea when this can be fixed?

    thx

    Wednesday, May 11, 2011 5:23 AM
  • The same for me :'(

    I changed from TableStorageSessionStateProvider because of this

    http://social.msdn.microsoft.com/Forums/en-US/windowsazuredevelopment/thread/6d3cfe64-a5e0-46e7-8497-a3593bb58abe/

    and now that I applied the very interesting AppFabric Cache, my reportviewer crashes.

    Please! Update de ReportViewer with a default constructor!!

    THXS!!!!

     

    Wednesday, May 11, 2011 7:00 AM
  • Hi Nithya,

     

    Has a date been set for this?  Or should we be looking at alternative solutions?

     

    Regards

    Sunday, June 26, 2011 12:29 PM
  • Hi, any chance to get this solved? I'm having the same problem.

    Thanks.


    Dánfer Habed López
    Thursday, November 03, 2011 4:45 PM
  • I am also having the same issue. It works fine when I create a separate solution for the reports but when I add the reports in the current project solution I am getting the same error. Any solution for this problem. Thanks!
    Wednesday, December 14, 2011 11:59 AM