Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>It looks like S#arp Architecture tries to use the same NHibernate session factory for both applications. It maybe colliding because it uses the same default 'factory key' (nhibernate.current_session) for both web apps when it persists configuration on disk. Should you be using different 'factory keys'? In order to do this you can read the <a href="https://github.com/sharparchitecture/Sharp-Architecture/wiki/Frequently-asked-questions" rel="nofollow">FAQ</a> section about multiple databases (although you don't have multiple databases, your solution may be the same):</p> <blockquote> <p>Q: How do I add support for multiple databases?</p> <p>A:: To add support for an additional database to your project:</p> <p>Create an NHibernateForOtherDb.config file which contains the connection string to the new database</p> <p>Within YourProject.Web.Mvc/Global.asax.cs, immediately under the NHibernateSession.Init() to initialize the first session factory, an additional call to NHibernateSession.AddConfiguration(). While the first NHibernate initialization assumes a default factory key, you'll need to provide an explicit factory key for the 2nd initialization. This factory key will be referred to by repositories which are tied to the new database as well...</p> </blockquote> <p>Looking at S#arp <a href="http://www.google.com/codesearch#d2g7OXjl48g/trunk/code/SharpArch.Data/NHibernate/NHibernateConfigurationFileCache.cs&amp;exact_package=http://novapangeia.googlecode.com/svn&amp;q=temp%20lang%3a%5Ec#%24&amp;type=cs&amp;l=121" rel="nofollow">sources</a> I found that they use following logic to create file on disk:</p> <pre><code> var fileName = string.Format( "{0}-{1}.bin", configKey, Assembly.GetCallingAssembly().CodeBase.GetHashCode()); </code></pre> <p>So if you don't want to change config/factory key you can try calling this code from different assembly.</p> <p>EDIT:</p> <p>It looks like <code>NHibernateSession.Init</code> does not take overload that lets you specify factory key. But it has other public methods that you can call <strong>instead</strong> of Init:</p> <pre><code>NHibernateSession.InitStorage(storage); try { NHibernateSession.AddConfiguration("%PUT YOUR OWN FACTORY KEY%", ...); } catch { NHibernateSession.Storage = null; throw; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload