Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SqlAuthenticationParameters.ConnectionTimeout throws MissingMethodException #1335

Closed
smichtch opened this issue Oct 12, 2021 · 3 comments · Fixed by #1336
Closed

SqlAuthenticationParameters.ConnectionTimeout throws MissingMethodException #1335

smichtch opened this issue Oct 12, 2021 · 3 comments · Fixed by #1336
Labels
🐛 Bug! Issues that are bugs in the drivers we maintain.

Comments

@smichtch
Copy link
Contributor

Describe the bug

SqlAuthenticationParameters.ConnectionTimeout throws MissingMethodException

System.MissingMethodException: Method not found: 'Int32 Microsoft.Data.SqlClient.SqlAuthenticationParameters.get_ConnectionTimeout()'.
   at Microsoft.Data.ProviderBase.DbConnectionPool.CheckPoolBlockingPeriod(Exception e)
   at Microsoft.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
   at Microsoft.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
   at Microsoft.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection)
   at Microsoft.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection)
   at Microsoft.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)
   at Microsoft.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
   at Microsoft.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
   at Microsoft.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry, SqlConnectionOverrides overrides)
   at Microsoft.Data.SqlClient.SqlConnection.Open(SqlConnectionOverrides overrides)
   at Microsoft.Data.SqlClient.SqlConnection.Open()
   at DatabaseTestController.TestSqlConnection(Action`1 customize)

To reproduce

Reproduces by accessing ConnectionTimeout from a custom SqlAuthenticationProvider:

class MyCustomSqlAuthenticationProvider : SqlAuthenticationProvider
{
    public override async Task<SqlAuthenticationToken> AcquireTokenAsync(SqlAuthenticationParameters parameters)
    {
        // System.MissingMethodException thrown here
        var connectionTimeout = parameters.ConnectionTimeout;
        ...
    }
    ...
}

Expected behavior

SqlAuthenticationParameters.ConnectionTimeout returns an integer value.

Further technical details

Microsoft.Data.SqlClient version: 3.0.1
.NET target: netcoreapp3.1 and net472
SQL Server version: N/A
Operating system: Windows 10 Enterprise Build 19043

Additional context
It looks like SqlAuthenticationParameters.ConnectionTimeout is implemented a a field

public int ConnectionTimeout = ADP.DefaultConnectionTimeout;

but in the ref assemblies it's a property:

public int ConnectionTimeout { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }

public int ConnectionTimeout { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }

Seems like it might just be a typo (i.e. impl missing a { get; }) but since SqlAuthenticationParameters is marked partial maybe I'm not seeing some generated code.

@cheenamalhotra
Copy link
Member

Hi @smichtch

I'm leaning to agree it should have been a property, but strangely it works fine for our provider implementation.

cts.CancelAfter(parameters.ConnectionTimeout * 1000); // Convert to milliseconds

but since SqlAuthenticationParameters is marked partial maybe I'm not seeing some generated code.

I think that is a left over keyword, the class is complete in ref project.

@smichtch
Copy link
Contributor Author

@cheenamalhotra ActiveDirectoryAuthenticationProvider in Microsoft.Data.SqlClient is not looking at the ref assemblies, it's getting the field from the implementation class directly:
image

@cheenamalhotra
Copy link
Member

Yes, I just tried in standalone and found this issue as well.

I've opened PR #1336 to address this, below package is built with this change, please try and let me know.

Add to local feed: Microsoft.Data.SqlClient.4.0.0-dev.nupkg.zip
<PackageReference Include="Microsoft.Data.SqlClient" Version="4.0.0-dev" />

Thanks for catching this bug 👍🏻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 Bug! Issues that are bugs in the drivers we maintain.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants