Конфигурация SQLite NHibernate с .Net 4.0 и 2010

Я обновляю этот пост тем, что, как мне кажется, теперь я знаю о получении этой конфигурации; ОДНАКО, есть еще что знать, так как у меня все еще есть проблема, это одна из важнейших областей.

Я использую SQLite для модульного тестирования, которое теперь работает нормально, используя шаги конфигурации ниже. Я также использую его, когда хочу выполнить тестовый интерфейс пользовательского интерфейса с большим количеством данных, чем тестовые данные в памяти, но без дополнительных затрат на SQLServer - эта конфигурация завершается ошибкой со следующим:

{"Could not create the driver from NHibernate.Driver.SQLite20Driver, NHibernate, Version=2.1.0.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4."}

Вот обновленная информация о конфигах, которые работают:

1) Какой SQLite DLL?Есть плохие ссылки, которые выглядят полезными, но в них есть ошибки сборки,только хорошая загрузка на эту датуздесь, в Source Forge, v1.066, который был выпущен сегодня, 4-18-2010.

2) Должны ли вы использовать GAC? Нет, как ответил Маурисио.

3) x64 builds - как ответил Маурисио.

4) Драйвер NHib - SQLite20Driver, ответил Маурисио

5) FNH как потенциальный конфликт - нет, как ответил Маурисио

Ура,
Berryl

== ДОБАВИТЬ ИНФОРМАЦИЮ О ОТЛАДКЕ ===

Когда возникает исключение, и я вызываю сборку SQLite20Drive, я получаю следующее, что подсказывает мне, что драйвердолжен быть доступным. Мне интересно, хотя, поскольку код конфигурации находится в другой сборке.

- сборка при ошибке ----

    ?typeof(SQLite20Driver).Assembly
{NHibernate, Version=2.1.0.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4}
[System.Reflection.RuntimeAssembly]: {NHibernate, Version=2.1.0.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4}
CodeBase: "file:///C:/Users/Lord & Master/Documents/Projects/Smack/trunk/src/ConstructionAdmin.WpfPresentation/bin/Debug/NHibernate.DLL"
EntryPoint: null
EscapedCodeBase: "file:///C:/Users/Lord%20%26%20Master/Documents/Projects/Smack/trunk/src/ConstructionAdmin.WpfPresentation/bin/Debug/NHibernate.DLL"
Evidence: {System.Security.Policy.Evidence}
FullName: "NHibernate, Version=2.1.0.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4"
GlobalAssemblyCache: false
HostContext: 0
ImageRuntimeVersion: "v2.0.50727"
IsDynamic: false
IsFullyTrusted: true
Location: "C:\\Users\\Lord & Master\\Documents\\Projects\\Smack\\trunk\\src\\ConstructionAdmin.WpfPresentation\\bin\\Debug\\NHibernate.dll"
ManifestModule: {NHibernate.dll}
PermissionSet: {<PermissionSet class="System.Security.PermissionSet"
version="1"
Unrestricted="true"/>
}
ReflectionOnly: false
SecurityRuleSet: Level1

--- сборка при модульном тестировании (НЕТ ОШИБКИ)

{NHibernate, Version=2.1.0.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4}
[System.Reflection.RuntimeAssembly]: {NHibernate, Version=2.1.0.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4}
CodeBase: "file:///C:/Users/Lord & Master/Documents/Projects/Smack/trunk/src/ConstructionAdmin.Tests/bin/Debug/NHibernate.DLL"
EntryPoint: null
EscapedCodeBase: "file:///C:/Users/Lord%20%26%20Master/Documents/Projects/Smack/trunk/src/ConstructionAdmin.Tests/bin/Debug/NHibernate.DLL"
Evidence: {System.Security.Policy.Evidence}
FullName: "NHibernate, Version=2.1.0.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4"
GlobalAssemblyCache: false
HostContext: 0
ImageRuntimeVersion: "v2.0.50727"
IsDynamic: false
IsFullyTrusted: true
Location: "C:\\Users\\Lord & Master\\Documents\\Projects\\Smack\\trunk\\src\\ConstructionAdmin.Tests\\bin\\Debug\\NHibernate.dll"
ManifestModule: {NHibernate.dll}
PermissionSet: {<PermissionSet class="System.Security.PermissionSet"

version = "1" Unrestricted = "true" />} ReflectionOnly: false SecurityRuleSet: Level1

Вот загрузчик для этого сеанса SQLite:

    /// <summary>SQLite-NHibernate bootstrapper for general use.</summary>
public class SQLiteBoot : IDisposable
{
    public readonly ISessionFactory SessionFactory;
    private readonly ISession _session;
    private static Configuration _config;
    private static string _persistenceModelGeneratorName;

    public SQLiteBoot(IAutoPersistenceModelGenerator persistenceModelGenerator) {
        if (_isSessionFactoryBuildRequired(persistenceModelGenerator)) {
            _config = new Configuration()
                .SetProperty(ENV.ReleaseConnections, "on_close")
                .SetProperty(ENV.Dialect, typeof (SQLiteDialect).AssemblyQualifiedName)
                .SetProperty(ENV.ConnectionDriver, typeof (SQLite20Driver).AssemblyQualifiedName)
                .SetProperty(ENV.ConnectionString, "data source=:memory:")
                .SetProperty(ENV.ProxyFactoryFactoryClass, typeof (ProxyFactoryFactory).AssemblyQualifiedName)
                .SetProperty(ENV.CurrentSessionContextClass, typeof (ThreadStaticSessionContext).AssemblyQualifiedName);

            _persistenceModelGeneratorName = persistenceModelGenerator.Name;
            var persistenceModel = persistenceModelGenerator.Generate();
            var fluentCfg = Fluently.Configure(_config).Mappings(m => m.AutoMappings.Add(persistenceModel));
            SessionFactory = fluentCfg.BuildSessionFactory();
            Check.Require(SessionFactory.GetAllClassMetadata().Count > 0, "No mapped classes - check your AutoPersistenceModel!");

        }

        _session = SessionFactory.OpenSession();
        CurrentSessionContext.Bind(_session);

        new SchemaExport(_config).Execute(true, true, false, _session.Connection, Console.Out);
    }

    private bool _isSessionFactoryBuildRequired(IAutoPersistenceModelGenerator persistenceModelGenerator)
    {
        return
            _config == null
            || SessionFactory == null
            || !persistenceModelGenerator.Name.Equals(_persistenceModelGeneratorName);
    }

    public void Dispose()
    {
        _session.Dispose();
    }
}

}

Ответы на вопрос(3)

Ваш ответ на вопрос