AccessViolationException when building session factory - hosted under IIS
Hi, we are writing an application to be hosted in IIS using WCF; we are using Fluent NHibernate and everything seems to work well when running our unit tests - we can create the mappings, the database tables and do entity persistence with no problems, however when we deploy to IIS we get the following exception when trying to call BuildSessionFactory() on a FluentConfiguration instance:
---> System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt. at System.Collections.Generic.Dictionary2.Insert(TKey key, TValue value, Boolean add) at System.Collections.Generic.Dictionary
2.Add(TKey key, TValue value) at System.Data.ProviderBase.DbConnectionFactory.GetConnectionPoolGroup(String connectionString, DbConnectionPoolGroupOptions poolOptions, DbConnectionOptions& userConnectionOptions) at System.Data.SqlClient.SqlConnection.ConnectionString_Set(String value) at NHibernate.Connection.DriverConnectionProvider.GetConnection() at NHibernate.Tool.hbm2ddl.SuppliedConnectionProviderConnectionHelper.Prepare() at NHibernate.Tool.hbm2ddl.SchemaMetadataUpdater.GetReservedWords(Dialect dialect, IConnectionHelper connectionHelper) at NHibernate.Tool.hbm2ddl.SchemaMetadataUpdater.Update(ISessionFactory sessionFactory) at NHibernate.Impl.SessionFactoryImpl..ctor(Configuration cfg, IMapping mapping, Settings settings, EventListeners listeners) at NHibernate.Cfg.Configuration.BuildSessionFactory() at FluentNHibernate.Cfg.FluentConfiguration.BuildSessionFactory() --- End of inner exception stack trace ---
All of our unit tests use the same bit of code to create the session factory, this problem only shows up when we deploy to IIS.
All PC's are running Windows 7 (64-bit).
Does anyone have any ideas what we are doing wrong?
Kind Regards,
Rich
2 Posted by Rich Lowden on 21 Jun, 2010 04:42 PM
Hi,
Quick update; the error seems to have gone away after doing the old turn it off and on again trick (iisreset). After doing this all seems to work OK
Regards