diff --git a/src/NServiceBus.Transport.SqlServer/SqlServerTransportInfrastructure.cs b/src/NServiceBus.Transport.SqlServer/SqlServerTransportInfrastructure.cs index 1dd8befbe..c00e7ce97 100644 --- a/src/NServiceBus.Transport.SqlServer/SqlServerTransportInfrastructure.cs +++ b/src/NServiceBus.Transport.SqlServer/SqlServerTransportInfrastructure.cs @@ -3,9 +3,15 @@ namespace NServiceBus.Transport.SqlServer using System; using System.Collections.Generic; using System.Linq; + using System.Reflection; using System.Threading; using System.Threading.Tasks; using System.Transactions; +#if SYSTEMDATASQLCLIENT + using System.Data.SqlClient; +#else + using Microsoft.Data.SqlClient; +#endif using Logging; using NServiceBus.Transport.SqlServer.PubSub; using Transport; @@ -21,6 +27,18 @@ internal SqlServerTransportInfrastructure(SqlServerTransport transport, HostSett tableBasedQueueCache = new TableBasedQueueCache(addressTranslator, !isEncrypted); connectionFactory = CreateConnectionFactory(); + + if (typeof(SqlConnection).Namespace != "Microsoft.Data.SqlClient") + { + return; + } + + var informationalVersion = typeof(SqlConnection).Assembly.GetCustomAttributes().OfType().Single(); + var currentClientVersion = new Version(informationalVersion.InformationalVersion.Split('+').First()); + if (currentClientVersion < new Version(5, 2, 0)) + { + _logger.WarnFormat("You are using an outdated version '{0}' of Microsoft.Data.SqlClient. We recommend using version 5.2.0 or later by adding a top-level package reference to avoid known problems in older versions of the client. Consult the SQL client release notes https://github.com/dotnet/SqlClient/blob/main/release-notes for breaking changes before upgrading.", currentClientVersion); + } } public async Task ConfigureSubscriptions(string catalog, CancellationToken cancellationToken = default)