I have migrated my project from MSSQL to MySQL and one of the feature I have to implement is a possibility to store sessions on db side, hence custom session store provider has to be configured. I used MySQL connector for visual studio to properly setup session provider. Here is a snippet from my web.config:
<connectionStrings>
<remove name="LocalMySqlServer" />
<add name="LocalMySqlServer" connectionString="server=<SERVER>;user=<USER>;pwd=<PASSWORD>;port=<PORT>;database=<DBNAME>;AutoEnlist=false;" providerName="MySql.Data.MySqlClient" />
</connectionStrings>
<system.web>
<sessionState mode="Custom" cookieless="false" timeout="20" allowCustomSqlDatabase="true" regenerateExpiredSessionId="true" customProvider="MySqlSessionStateProvider">
<providers>
<clear/>
<add name="MySqlSessionStateProvider" type="MySql.Web.SessionState.MySqlSessionStateStore, MySql.Web, Version=6.9.8.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" applicationName="/" description="My Local Session State" connectionStringName="LocalMySqlServer" writeExceptionsToEventLog="True" autogenerateschema="True" enableExpireCallback="False" />
</providers>
</sessionState>
...
</system.web>
Once I run my application db schema was modified and all required tables were created:
Furthermore, I detected that during execution session table is filling by session info so I it is a good signal that connection works and MySQL custom provider is doing what is supposed to do.
Unfortunately, after some time my application fails due to System.OutOfMemoryException. The stack trace looks like:
My assumption is that there is some problem with session items deserialization. I have a few classes which are stored in a session and all of them are marked by appropriate [Serializable]
attribute. Other items has primitive types (bool, int..) So, my question is what else could cause this issue? The problem is that I even can't detect exact place from where this issue is firing. Any suggestion are appreciated.