服务帐户在NServiceBus启动时抛出SQLiteException

时间:2011-02-09 22:41:50

标签: sqlite nservicebus

当我尝试使用服务帐户凭据启动nservicebus.host.exe时,我收到以下异常:

    Database was not configured through Database method.  
System.Data.SQLite.SQLiteException: Unable to open the database file  
at System.Data.SQLite.SQLite3.Open(String strFilename, SQLiteOpenFlagsEnum flags, Int32 maxPoolSize, Boolean usePool)  
at System.Data.SQLite.SQLiteConnection.Open()
at NHibernate.Connection.DriverConnectionProvider.GetConnection() in :line 0
at NHibernate.Tool.hbm2ddl.SuppliedConnectionProviderConnectionHelper.Prepare() in :line 0
at NHibernate.Tool.hbm2ddl.SchemaMetadataUpdater.GetReservedWords(Dialect dialect, IConnectionHelper connectionHelper) in :line 0
at NHibernate.Tool.hbm2ddl.SchemaMetadataUpdater.Update(ISessionFactory sessionFactory) in :line 0
at NHibernate.Impl.SessionFactoryImpl..ctor(Configuration cfg, IMapping mapping, Settings settings, EventListeners listeners) in :line 0
at FluentNHibernate.Cfg.FluentConfiguration.BuildSessionFactory() in D:\dev\fluent-nhibernate\src\FluentNHibernate\Cfg\FluentConfiguration.cs:line 93
--- End of inner exception stack trace ---
at FluentNHibernate.Cfg.FluentConfiguration.BuildSessionFactory() in D:\dev\fluent-nhibernate\src\FluentNHibernate\Cfg\FluentConfiguration.cs:line 100
at NServiceBus.SagaPersisters.NHibernate.Config.Internal.SessionFactoryBuilder.Build(IDictionary^2 nhibernateProperties, Boolean updateSchema) in c:\Dev\DotNet\NServiceBus\src\impl\SagaPersisters\NHibernateSagaPersister\NServiceBus.SagaPersisters.NHibernate.Config\Internal\SessionFactoryBuilder.cs:line 48
--- End of inner exception stack trace ---
at NServiceBus.SagaPersisters.NHibernate.Config.Internal.SessionFactoryBuilder.Build(IDictionary^2 nhibernateProperties, Boolean updateSchema) in c:\Dev\DotNet\NServiceBus\src\impl\SagaPersisters\NHibernateSagaPersister\NServiceBus.SagaPersisters.NHibernate.Config\Internal\SessionFactoryBuilder.cs:line 55
at NServiceBus.ConfigureNHibernateSagaPersister.NHibernateSagaPersister(Configure config, IDictionary^2 nhibernateProperties, Boolean autoUpdateSchema) in c:\Dev\DotNet\NServiceBus\src\impl\SagaPersisters\NHibernateSagaPersister\NServiceBus.SagaPersisters.NHibernate.Config\ConfigureNHibernateSagaPersister.cs:line 80
at Ibfx.BackOffice.Services.NewAccounts.NewAccountsEndpoint.Init() in C:\Dev\TFS\Omega\Src\Svcs\NewAccounts\Src\Service\NewAccountsEndpoint.cs:line 67
at NServiceBus.Host.Internal.GenericHost.Start() in c:\Dev\DotNet\NServiceBus\src\host\NServiceBus.Host\Internal\GenericHost.cs:line 56

如果我使用自己的帐户运行主机,一切正常,但如果我将主机作为具有域凭据的服务运行,或者使用RunAs命令使用相同的凭据,我会得到上述异常。我需要配置哪些权限才能使服务正常工作?

这是我的配置:

        var configure = NServiceBus.Configure.With()
            .Log4Net<Log4NetLoggerAdapter>(a => { })
            .UnityBuilder(container)
            .XmlSerializer()
            .RijndaelEncryptionService()
            .MsmqTransport()
                .IsTransactional(false)
                .PurgeOnStartup(false)
                .MsmqSubscriptionStorage();

        configure.Configurer.ConfigureComponent<MsmqSubscriptionStorage>(
                    ComponentCallModelEnum.None).ConfigureProperty(p => p.DontUseExternalTransaction
                    , true
                );

        IBus bus = configure.UnicastBus()
            .ImpersonateSender(true)
            .LoadMessageHandlers()
            .Sagas()
            .NHibernateSagaPersister()
        .CreateBus()
        .Start();

我有一个NServiceBus.Host.exe.config文件,其中包含以下内容:

&lt;?xml version =“1.0”encoding =“utf-8”?&gt; &LT;结构&gt;     &lt; startup useLegacyV2RuntimeActivationPolicy =“true”&gt;         &lt; supportedRuntime version =“v4.0”/&gt;     &LT; /启动&GT; &LT; /结构&gt;

1 个答案:

答案 0 :(得分:2)

暂时给所有人和ANONYMOUS LOGON完全控制所指定的目录时会发生什么?如果这解决了异常,那肯定是一个安全问题。你在使用| DataDirectory |在你的连接字符串?您确定该过程实际上是在查看您认为正在查看的目录吗?

接下来,我会尝试在内存连接字符串设置中使用SQLite,看看它是否能够至少创建一个数据库并使用它:

":memory:;Version=3;New=True;Pooling=True;Max Pool Size=1;"

上面的字符串使用内存中的SQLite,但保持单个连接打开,以便表和数据继续存在,直到进程退出。

我将使用的另一个策略是将saga persister更改为另一种SQL风格,例如MS SQL,以查看是否能解决它。