Hi,

Our application runs on 2 websites. The 1 website is a Project Management tool (called PAD) and the other is a website used for Reporting (called REP). Both use the same database but a different Class Model.

Now PAD runs flawless without any problems. But as soon as we use the REP website, PAD gets an ObjectDisposedException (message = "Cannot access a disposed object.\r\nObject name: 'Session is already disposed.'") but not always.

Reporting works like this:

  1. A client calls a controller on the PAD website and the controller writes report parameters in the DB.
  2. On return to the client the Id of the parameter row is returned.
  3. The client then calls the REP website which reads the Reporting parameters and produces a Report that is displayed on the website.

The Reporting tool uses multiple threads to generate the report and that is the reason why we added the 'AllowSwitching' to the configuration. Could that cause our problems?

Here's the configuration used for DataObjects.Net.

  <Xtensive.Orm>
<domains>
  <!-- The PerformSafely attribute below can be overwritten in the DataContext.OpenSession() -->
  <domain name="Default" defaultSchema="DataObjects" provider="sqlserver" connectionString="Data Source=localhost;Initial Catalog=Controlit_Facturatie;Persist Security Info=True;Integrated Security=True;MultipleActiveResultSets=True" upgradeMode="PerformSafely">
    <mappingRules>
      <rule namespace="Projecten.Model.Entities" schema="Projecten" />
      <rule namespace="Fortrus.Reporting.Model.Entities" schema="Reporting" />
    </mappingRules>
    <types>
      <add assembly="Fortrus.Reporting.Model" />
      <add assembly="Projecten.Model" />
      <!--<add assembly="Xtensive.Orm.Security"/>-->
    </types>
    <sessions>
      <!-- AllowSwitching is nodig voor Telerik Reporting om Session switching toe te staan 
                     Telerik werkt nl. met worker threads en dat veroorzaakt een exception wanneer deze
                     optie niet aan staat -->
      <session name="default" options="ServerProfile,AllowSwitching" />
    </sessions>
  </domain>
</domains>

</xtensive.orm>

Regards

Paul Sinnema

asked May 02 '13 at 07:07

Paul%20Sinnema's gravatar image

Paul Sinnema
261878896

edited May 02 '13 at 07:08


One Answer:

Hello Paul,

it seems that some session becames activated manually without proper deactivation.

Session.Resolver (that is used by SessionManager from Xtensive.Orm.Web) is taken into account only when no session is activated. If some session is activated manually and is not deactivated properly it permanently becames default session for current thread. Since ASP.NET typically uses a pool of threads to serve requests this leads to the behavior you experience: random errors with message about disposed session.

What you should check at the first time:

  • Manual Session.Activate() calls without disposing the result
  • Query or EntitySet enumeration without disposing corresponding IEnumerator

answered May 06 '13 at 05:24

Denis%20Krjuchkov's gravatar image

Denis Krjuchkov
179325

  • Yes, we do use the Activate on some occasions. I'll take a look at that.
  • Enumerations take only place in the local scope of a method. The result has the local scope only and should be disposed automatically, right?
(May 06 '13 at 05:43) Paul Sinnema Paul%20Sinnema's gravatar image

foreach operator and LINQ extension methods always dispose obtained enumerator. Problem could appear if you manually call GetEnumerator() or use some third-party library that handles this incorrectly.

(May 06 '13 at 05:48) Denis Krjuchkov Denis%20Krjuchkov's gravatar image
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!
toggle preview

powered by OSQA