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

SqlConnectionStringBuilder class missing HostNameInCertificate property #1775

Closed
nemanja-milovancevic opened this issue Sep 27, 2022 · 7 comments · Fixed by #1776
Closed

Comments

@nemanja-milovancevic
Copy link

Describe the bug

SqlConnectionStringBuilder class is missing the HostNameInCertificate property on the net462 and net472. It's present on the net6.0.

To reproduce

csproj file:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net462</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.Data.SqlClient" Version="5.0.0" />
  </ItemGroup>

</Project>

C# file:

using Microsoft.Data.SqlClient;

namespace Example
{
    class Example
    {
        public static void Main()
        {
            SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder();
            builder.HostNameInCertificate = "";
        }
    }
}

If you change the target version to net6.0 it will work.

Expected behavior

According to the docs MDS5.0.0 should be supported on net462 and above. Important part of that is TDS 8.0 support.

Further technical details

Microsoft.Data.SqlClient version: 5.0.0
.NET target: Framework 4.6.2, 4.7.2
SQL Server version: N/A
Operating system: Windows Server 2019

Additional context
We're working on updating ADS to the TDS 8.0 and we can't do it without MDS support.

@lcheunglci
Copy link
Contributor

lcheunglci commented Sep 27, 2022

Hi @nemanja-milovancevic , thanks for bringing the missing HostNameInCertificate property in the SqlConnectionStringBuilder to our attention. However, I did just quick check with your repro steps on a .NET Framework 4.6.2 project, and verified that on M.D.SqlClient 5.0 GA, the HostNameInCertificate does work as expected and is a public property for both .NET Core and .NET Framework and according to the implementation here, the changes applies to both netfx and netcore, so it should be supported. There are also functional tests to check that HNIC is a valid keyword so it can be used when you specify it from connection string in the constructor of SqlConnectionStringBuilder.

@nemanja-milovancevic
Copy link
Author

Interesting, it's working when I use builder["HostNameInCertificate"] = "" instead of builder.HostNameInCertificate = ""

@cheenamalhotra
Copy link
Member

@lcheunglci

The issue seems to be due to missing refs in .NET Framework ref project. Please find PR #1776 to fix the same.

@lcheunglci
Copy link
Contributor

Thanks @cheenamalhotra !

@lcheunglci lcheunglci added this to the 5.1.0-preview1 milestone Sep 27, 2022
@DavoudEshtehari DavoudEshtehari removed this from the 5.1.0-preview1 milestone Sep 28, 2022
@shueybubbles
Copy link

remind me - why do you bother maintaining separate "ref" DLLs instead of just having the compiler reference the full DLLs in the lib folder?

@lcheunglci lcheunglci linked a pull request Oct 11, 2022 that will close this issue
@lcheunglci
Copy link
Contributor

@nemanja-milovancevic The fix has been merged in the 5.0.1 release.

@nemanja-milovancevic
Copy link
Author

@cheenamalhotra @lcheunglci Thanks for fixing this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants