dotnet/orleans · error · OrleansConfigurationException

Invalid {nameof(AdoNetStreamOptions)} values for ADO.NET Str

Error message

Invalid {nameof(AdoNetStreamOptions)} values for ADO.NET Streaming Provider '{name}': configure exactly one of {nameof(options.ConnectionString)} or {nameof(options.DataSource)}.

What it means

Thrown by the ADO.NET streaming options validator when both ConnectionString and DataSource are set, or neither is. The stream provider needs exactly one connection source per named provider. The equality check fires for both the all-unset and both-set cases.

Source

Thrown at src/AdoNet/Orleans.Streaming.AdoNet/AdoNetStreamOptionsValidator.cs:20

namespace Orleans.Configuration;

/// <summary>
/// Validates <see cref="AdoNetStreamOptions"/> configuration.
/// </summary>
public class AdoNetStreamOptionsValidator(AdoNetStreamOptions options, string name) : IConfigurationValidator
{
    /// <inheritdoc />
    public void ValidateConfiguration()
    {
        if (IsNullOrWhiteSpace(options.Invariant))
        {
            throw new OrleansConfigurationException($"Invalid {nameof(AdoNetStreamOptions)} values for ADO.NET Streaming Provider '{name}': {nameof(options.Invariant)} is required.");
        }

        if (IsNullOrWhiteSpace(options.ConnectionString) == (options.DataSource is null))
        {
            throw new OrleansConfigurationException($"Invalid {nameof(AdoNetStreamOptions)} values for ADO.NET Streaming Provider '{name}': configure exactly one of {nameof(options.ConnectionString)} or {nameof(options.DataSource)}.");
        }

        if (options.MaxAttempts < 0)
        {
            throw new OrleansConfigurationException($"Invalid {nameof(AdoNetStreamOptions)} values for ADO.NET Streaming Provider '{name}': {nameof(options.MaxAttempts)} must be greater than zero.");
        }

        if (options.VisibilityTimeout < TimeSpan.Zero)
        {
            throw new OrleansConfigurationException($"Invalid {nameof(AdoNetStreamOptions)} values for ADO.NET Streaming Provider '{name}': {nameof(options.VisibilityTimeout)} must be greater than zero.");
        }

        if (options.EvictionInterval < TimeSpan.Zero)
        {
            throw new OrleansConfigurationException($"Invalid {nameof(AdoNetStreamOptions)} values for ADO.NET Streaming Provider '{name}': {nameof(options.EvictionInterval)} must be greater than zero.");
        }

        if (options.ExpiryTimeout < TimeSpan.Zero)

View on GitHub (pinned to fca799fa70)

Solutions

  1. Provide exactly one of options.ConnectionString or options.DataSource per provider.
  2. Remove the redundant field if migrating between the two.
  3. Confirm the appsettings.json stream-provider section has exactly one connection field.

Example fix

// before
builder.AddAdoNetStreams("ads", o =>
{
    o.Invariant = AdoNetInvariants.InvariantNameSqlServer;
});

// after
builder.AddAdoNetStreams("ads", o =>
{
    o.Invariant = AdoNetInvariants.InvariantNameSqlServer;
    o.ConnectionString = "Server=.;Database=Orleans;Trusted_Connection=True;";
});
Defensive patterns

Strategy: validation

Validate before calling

static void CheckStreamConnection(AdoNetStreamOptions o)
{
    var exactlyOne = string.IsNullOrWhiteSpace(o.ConnectionString) != (o.DataSource is null);
    if (!exactlyOne)
        throw new InvalidOperationException("Set exactly one of ConnectionString or DataSource per stream provider.");
}

Prevention

When it happens

Trigger: ValidateConfiguration() runs on AdoNetStreamOptions where IsNullOrWhiteSpace(ConnectionString) equals (DataSource is null). Occurs when only Invariant is set, or when both a ConnectionString and DbDataSource are supplied for the same provider name.

Common situations: Configuring the provider with Invariant but no connection; supplying a ConnectionString while also injecting a DbDataSource for pooling; mid-migration leaving both populated.

Related errors


AI-assisted analysis of dotnet/orleans@fca799fa70 (2026-08-13). Data as JSON: /api/errors/a7b323424dd1322f. Report an issue: GitHub.