About once a day I was getting the following error from an ASP.Net web page that uses ActiveRecord:
Exception Details: System.Data.SqlClient.SqlException: A transport-level error has occurred when sending the request to the server. (provider: TCP Provider, error: 0 - An existing connection was forcibly closed by the remote host.)
I would subsequently get this error upon refreshing the page:
Exception Details: System.InvalidOperationException: ExecuteReader requires an open and available Connection. The connection's current state is closed.
I finally figured out that the problem occurs when the database is restored. The connections in the IIS application pool do not get destroyed when the database is restored, so when ActiveRecord (nHibernate) tries to reuse the connections it fails. This doesn't happen to me when I'm not using ActiveRecord, so I'm not sure if this is a bug with ActiveRecord or a problem with the way I've set up the data access layer.