これが重複した投稿であることはわかっていますが、私のコンテキストは異なります。hereからこの問題の解決策を調べました。そして、私は次のように変更しました:
private static Mutex _sessionMutex = new Mutex();
public void OpenMySessionFactory(string conStr)
{
try
{
_sessionMutex.WaitOne();
config = Fluently.Configure()
.Database(MySQLConfiguration.Standard.ConnectionString(conStr))
.Mappings(m => m.FluentMappings.AddFromAssembly(System.Reflection.Assembly.GetExecutingAssembly()))
.BuildConfiguration();
sessionFactory = config.BuildSessionFactory();
_sessionMutex.ReleaseMutex();
}
catch (Exception)
{
throw;
}
}
上記のように実装した場合、何か影響はありますか?
エラーの理由:
同じキーを持つアイテムが既に追加されています
Fluent NHibernateを使用してデータアクセスで何かをしなければならないボタンをダブルクリックすると発生します。