Configuração do SQLite NHibernate com .Net 4.0 e vs 2010

Estou atualizando este post com o que acho que agora sei sobre obter essa configuração; No entanto, há mais a saber, pois ainda estou tendo um problema, é uma área crucial.

Eu uso o SQLite para teste de unidade, que agora funciona bem, usando as etapas de configuração abaixo. Também o uso quando quero uma execução de teste da interface do usuário com mais dados do que na memória, mas sem a sobrecarga do SQLServer - essa configuração falha com o seguinte:

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

Aqui estão informações atualizadas sobre configurações que funcionam:

1) Qual dll SQLite ??Existem alguns links ruins por aí que parecem úteis, mas que contêm erros de construção. osó bom download a partir desta data éaqui no Source Forge. v1.066, lançado hoje, 4-18-2010.

2) Você deve usar o GAC? Não, como respondido por Mauricio.

3) x64 builds - conforme respondido por Mauricio.

4) Driver NHib - SQLite20Driver, respondido por Mauricio

5) HNF como um conflito potencial - não, conforme respondido por Mauricio

Felicidades,
Berryl

== ADICIONAR INFO DEBUG ===

Quando a exceção é atingida e eu chamo o assembly SQLite20Drive, recebo o seguinte, que sugere para mim que o driverdevemos estar disponível. Estou pensando, porém, como o código de configuração está em um assembly diferente.

- montagem quando erro ----

    ?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

--- montagem ao testar a unidade (SEM ERRO)

{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

Aqui está o bootstrapper para esta sessão 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();
    }
}

}

questionAnswers(3)

yourAnswerToTheQuestion