Home All Groups Group Topic Archive Search About

Error with partitioned session

Author
28 Jun 2006 8:33 PM
Demi
Running ASP.NET2.  Every once in a while I get this error:

Unable to cast object of type 'System.Collections.DictionaryEntry' to type
'System.Web.PartitionInfo'.

   at System.Web.PartitionManager.Dispose()
   at System.Web.SessionState.SqlSessionStateStore.OnAppDomainUnload(Object
unusedObject, EventArgs unusedEventArgs)

I setup a partitioned session db by overriding
System.Web.IPartitionResolver and using a simple hash to return an index in
a list of connection strings.

        public String ResolvePartition(Object key)
        {
            String sid = (String)key;

            // hash the incoming session ID into
            // one of the available partitions
            int partitionID = Math.Abs(sid.GetHashCode()) % partitions.Length;

            return partitions[partitionID];
        }

I did it based on the article here:
http://msdn.microsoft.com/msdnmag/issues/05/09/SessionState/default.aspx#S8
and just did the sessiondb instead of the session state server.  As I said
works fine most of the time but throws the above exception once in a while.

Author
28 Jun 2006 8:41 PM
Demi
Very repeatable.  If I change web.config to force the appdomain unload, this
happens.

Show quote
"Demi" wrote:

>
> Running ASP.NET2.  Every once in a while I get this error:
>
> Unable to cast object of type 'System.Collections.DictionaryEntry' to type
> 'System.Web.PartitionInfo'.
>
>    at System.Web.PartitionManager.Dispose()
>    at System.Web.SessionState.SqlSessionStateStore.OnAppDomainUnload(Object
> unusedObject, EventArgs unusedEventArgs)
>
> I setup a partitioned session db by overriding
> System.Web.IPartitionResolver and using a simple hash to return an index in
> a list of connection strings.
>
>         public String ResolvePartition(Object key)
>         {
>             String sid = (String)key;
>
>             // hash the incoming session ID into
>             // one of the available partitions
>             int partitionID = Math.Abs(sid.GetHashCode()) % partitions.Length;
>
>             return partitions[partitionID];
>         }
>
> I did it based on the article here:
> http://msdn.microsoft.com/msdnmag/issues/05/09/SessionState/default.aspx#S8
> and just did the sessiondb instead of the session state server.  As I said
> works fine most of the time but throws the above exception once in a while.

AddThis Social Bookmark Button