RoxSeibert
RoxSeibert

Reputation: 1

Quartz.net Could not Initialize DataSource for SqlServer-20

I'm new to running Quartz v3.5.0 on .NET framework 4.8 as a Windows service in an Autofac IoC. I had it working just fine with a RAMJobStore. But now that I created a QuartzData database (as prescribed) in MS Sql Server on my localhost, I seem to be missing something.

I keep getting a Quartz.SchedulerException: 'Could not Initialize DataSource: default' on my .GetScheduler() call, due to an ArgumentOutOfRangeException: There is no metadata information for provider 'SqlServer-20' Parameter name: providerName.

My App.config (UPDATED for a better connection string but the problem still exists)

<quartz>
    <add key="quartz.scheduler.instanceName" value="DefaultQuartzScheduler" />
    <add key="quartz.scheduler.instanceId" value="instance_one" />
    <add key="quartz.threadPool.type" value="Quartz.Simpl.SimpleThreadPool, Quartz" />
    <add key="quartz.threadPool.threadCount" value="5" />
    
    <add key="quartz.jobStore.misfireThreshold" value="60000" />
    <add key="quartz.serializer.type" value="json" />
    <add key="quartz.jobStore.clustered" value="false" />
    <!--<add key="quartz.jobStore.lockHandler.type" value="Quartz.Impl.AdoJobStore.UpdateLockRowSemaphore, Quartz"/>
    -->
    
    <add key="quartz.jobStore.type" value="Quartz.Impl.AdoJobStore.JobStoreTX, Quartz" />
    <add key="quartz.jobStore.useProperties" value="true" />
      <add key="quartz.jobStore.tablePrefix" value="QRTZ_" />
    
    <add key="quartz.jobStore.driverDelegateType" value="Quartz.Impl.AdoJobStore.SqlServerDelegate, Quartz" />
    <add key="quartz.jobStore.dataSource" value="default" />
    <add key="quartz.dataSource.default.connectionString" value="Server=localhost;Database=QuartzData;Uid=XXX;Pwd=XXX" />
    <add key="quartz.dataSource.default.provider" value="SqlServer-20" />
</quartz>

My Program.cs

        var config = (NameValueCollection)ConfigurationManager.GetSection("quartz");

        ISchedulerFactory schedulerFactory = new StdSchedulerFactory(config);
        IScheduler Scheduler = schedulerFactory.GetScheduler().GetAwaiter().GetResult();

Thanks in advance for your help.

Upvotes: 0

Views: 920

Answers (1)

RoxSeibert
RoxSeibert

Reputation: 1

The resolution to this problem was to set the properties on my app.config to always copy to output directory.

I had a bad connection string early on. And that got stuck in my bin because my revised app.config settings weren't overwriting the old settings.

Upvotes: 0

Related Questions