dotnet / SqlClient

Microsoft.Data.SqlClient provides database connectivity to SQL Server for .NET applications.
MIT License
847 stars 282 forks source link

Upgrade to 4.0, I get a message when the app runs in an installer can't find Microsoft.Data.SqlClient 3.0.0 #1448

Open DataJuggler opened 2 years ago

DataJuggler commented 2 years ago

Describe the bug

I updaded a project and Nuget package to .NET6, updgraded from System.Data.SqlClient to Microsoft.Data.SqlClient 4.0.0, and the installer runs. When I try and connect to a database, I get the error can't find Microsoft.Data.SqlClient version 3.0.0.

With packages references I knew how to add a binding redirect, I don't see how to that in a Project file.

Just a comment, your breaking change of 'Encrypt = true' now by default. I went the other way. I started off with encryption by default in 2010 and decided in 2019 it was time to make it Encrypted = false. You broke my project DB Compare, because people paste in connection strings, and they won't work now. I wish this was an option, not a dictate by you. Not everyone is as paranoid about security as you are.

Can someone explain to me how to force the entire app to use 4.0.0 version?

If you are seeing an exception, include the full exceptions details (message and stack trace).

** Exception Text ** System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Data.SqlClient, Version=3.0.0.0, Culture=neutral, PublicKeyToken=23ec7fc2d6eaa4a5'. The system cannot find the file specified. File name: 'Microsoft.Data.SqlClient, Version=3.0.0.0, Culture=neutral, PublicKeyToken=23ec7fc2d6eaa4a5' at DataJuggler.Net6.ConnectionStringHelper.BuildConnectionString(String serverName, String databaseName) at DBCompare.ConnectionStringBuilderForm.BuildConnectionStringButton_Click(Object sender, EventArgs e) in C:\Projects\GitHub\DBCompare\DBCompare\ConnectionStringBuilderForm.cs:line 65 at System.Windows.Forms.Control.OnClick(EventArgs e) at System.Windows.Forms.Button.OnClick(EventArgs e) at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent) at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.ButtonBase.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, WM msg, IntPtr wparam, IntPtr lparam)

** Loaded Assemblies ** System.Private.CoreLib Assembly Version: 6.0.0.0 Win32 Version: 6.0.121.56705 CodeBase: file:///C:/Program%20Files/dotnet/shared/Microsoft.NETCore.App/6.0.1/System.Private.CoreLib.dll

DBCompare Assembly Version: 6.0.0.0 Win32 Version: 6.0.0.0 CodeBase: file:///C:/Program%20Files%20(x86)/Data%20Juggler/DB%20Compare/DBCompare.dll

System.Runtime Assembly Version: 6.0.0.0 Win32 Version: 6.0.121.56705 CodeBase: file:///C:/Program%20Files/dotnet/shared/Microsoft.NETCore.App/6.0.1/System.Runtime.dll

System.Windows.Forms Assembly Version: 6.0.1.0 Win32 Version: 6.0.121.56705 CodeBase: file:///C:/Program%20Files/dotnet/shared/Microsoft.WindowsDesktop.App/6.0.1/System.Windows.Forms.dll

System.ComponentModel.Primitives Assembly Version: 6.0.0.0 Win32 Version: 6.0.121.56705 CodeBase: file:///C:/Program%20Files/dotnet/shared/Microsoft.NETCore.App/6.0.1/System.ComponentModel.Primitives.dll

System.Windows.Forms.Primitives Assembly Version: 6.0.1.0 Win32 Version: 6.0.121.56705 CodeBase: file:///C:/Program%20Files/dotnet/shared/Microsoft.WindowsDesktop.App/6.0.1/System.Windows.Forms.Primitives.dll

System.Runtime.InteropServices Assembly Version: 6.0.0.0 Win32 Version: 6.0.121.56705 CodeBase: file:///C:/Program%20Files/dotnet/shared/Microsoft.NETCore.App/6.0.1/System.Runtime.InteropServices.dll

System.Drawing.Primitives Assembly Version: 6.0.0.0 Win32 Version: 6.0.121.56705 CodeBase: file:///C:/Program%20Files/dotnet/shared/Microsoft.NETCore.App/6.0.1/System.Drawing.Primitives.dll

System.Collections.Specialized Assembly Version: 6.0.0.0 Win32 Version: 6.0.121.56705 CodeBase: file:///C:/Program%20Files/dotnet/shared/Microsoft.NETCore.App/6.0.1/System.Collections.Specialized.dll

DataJuggler.Win.Controls Assembly Version: 5.8.9.0 Win32 Version: 5.8.9.0 CodeBase: file:///C:/Program%20Files%20(x86)/Data%20Juggler/DB%20Compare/DataJuggler.Win.Controls.dll

System.Threading Assembly Version: 6.0.0.0 Win32 Version: 6.0.121.56705 CodeBase: file:///C:/Program%20Files/dotnet/shared/Microsoft.NETCore.App/6.0.1/System.Threading.dll

System.Diagnostics.TraceSource Assembly Version: 6.0.0.0 Win32 Version: 6.0.121.56705 CodeBase: file:///C:/Program%20Files/dotnet/shared/Microsoft.NETCore.App/6.0.1/System.Diagnostics.TraceSource.dll

System.Collections Assembly Version: 6.0.0.0 Win32 Version: 6.0.121.56705 CodeBase: file:///C:/Program%20Files/dotnet/shared/Microsoft.NETCore.App/6.0.1/System.Collections.dll

System.Drawing.Common Assembly Version: 6.0.0.0 Win32 Version: 6.0.121.56705 CodeBase: file:///C:/Program%20Files/dotnet/shared/Microsoft.WindowsDesktop.App/6.0.1/System.Drawing.Common.dll

Microsoft.Win32.Primitives Assembly Version: 6.0.0.0 Win32 Version: 6.0.121.56705 CodeBase: file:///C:/Program%20Files/dotnet/shared/Microsoft.NETCore.App/6.0.1/Microsoft.Win32.Primitives.dll

System.ComponentModel.EventBasedAsync Assembly Version: 6.0.0.0 Win32 Version: 6.0.121.56705 CodeBase: file:///C:/Program%20Files/dotnet/shared/Microsoft.NETCore.App/6.0.1/System.ComponentModel.EventBasedAsync.dll

System.Threading.Thread Assembly Version: 6.0.0.0 Win32 Version: 6.0.121.56705 CodeBase: file:///C:/Program%20Files/dotnet/shared/Microsoft.NETCore.App/6.0.1/System.Threading.Thread.dll

Accessibility Assembly Version: 4.0.0.0 Win32 Version: 6.0.121.56705 CodeBase: file:///C:/Program%20Files/dotnet/shared/Microsoft.WindowsDesktop.App/6.0.1/Accessibility.dll

System.ComponentModel.TypeConverter Assembly Version: 6.0.0.0 Win32 Version: 6.0.121.56705 CodeBase: file:///C:/Program%20Files/dotnet/shared/Microsoft.NETCore.App/6.0.1/System.ComponentModel.TypeConverter.dll

System.ComponentModel Assembly Version: 6.0.0.0 Win32 Version: 6.0.121.56705 CodeBase: file:///C:/Program%20Files/dotnet/shared/Microsoft.NETCore.App/6.0.1/System.ComponentModel.dll

System.Numerics.Vectors Assembly Version: 6.0.0.0 Win32 Version: 6.0.121.56705 CodeBase: file:///C:/Program%20Files/dotnet/shared/Microsoft.NETCore.App/6.0.1/System.Numerics.Vectors.dll

Microsoft.Win32.SystemEvents Assembly Version: 6.0.0.0 Win32 Version: 6.0.121.56705 CodeBase: file:///C:/Program%20Files/dotnet/shared/Microsoft.WindowsDesktop.App/6.0.1/Microsoft.Win32.SystemEvents.dll

System.Resources.Extensions Assembly Version: 6.0.0.0 Win32 Version: 6.0.121.56705 CodeBase: file:///C:/Program%20Files/dotnet/shared/Microsoft.WindowsDesktop.App/6.0.1/System.Resources.Extensions.dll

System.Memory Assembly Version: 6.0.0.0 Win32 Version: 6.0.121.56705 CodeBase: file:///C:/Program%20Files/dotnet/shared/Microsoft.NETCore.App/6.0.1/System.Memory.dll

System.Drawing Assembly Version: 6.0.1.0 Win32 Version: 6.0.121.56705 CodeBase: file:///C:/Program%20Files/dotnet/shared/Microsoft.WindowsDesktop.App/6.0.1/System.Drawing.dll

System.ObjectModel Assembly Version: 6.0.0.0 Win32 Version: 6.0.121.56705 CodeBase: file:///C:/Program%20Files/dotnet/shared/Microsoft.NETCore.App/6.0.1/System.ObjectModel.dll

System.Linq Assembly Version: 6.0.0.0 Win32 Version: 6.0.121.56705 CodeBase: file:///C:/Program%20Files/dotnet/shared/Microsoft.NETCore.App/6.0.1/System.Linq.dll

System.Collections.NonGeneric Assembly Version: 6.0.0.0 Win32 Version: 6.0.121.56705 CodeBase: file:///C:/Program%20Files/dotnet/shared/Microsoft.NETCore.App/6.0.1/System.Collections.NonGeneric.dll

System.Configuration.ConfigurationManager Assembly Version: 6.0.0.0 Win32 Version: 6.0.121.56705 CodeBase: file:///C:/Program%20Files/dotnet/shared/Microsoft.WindowsDesktop.App/6.0.1/System.Configuration.ConfigurationManager.dll

DataJuggler.UltimateHelper Assembly Version: 1.6.8.0 Win32 Version: 1.6.8.0 CodeBase: file:///C:/Program%20Files%20(x86)/Data%20Juggler/DB%20Compare/DataJuggler.UltimateHelper.dll

System.Private.Uri Assembly Version: 6.0.0.0 Win32 Version: 6.0.121.56705 CodeBase: file:///C:/Program%20Files/dotnet/shared/Microsoft.NETCore.App/6.0.1/System.Private.Uri.dll

System.Runtime.InteropServices.RuntimeInformation Assembly Version: 6.0.0.0 Win32 Version: 6.0.121.56705 CodeBase: file:///C:/Program%20Files/dotnet/shared/Microsoft.NETCore.App/6.0.1/System.Runtime.InteropServices.RuntimeInformation.dll

System.Security.Cryptography.Algorithms Assembly Version: 6.0.0.0 Win32 Version: 6.0.121.56705 CodeBase: file:///C:/Program%20Files/dotnet/shared/Microsoft.NETCore.App/6.0.1/System.Security.Cryptography.Algorithms.dll

System.Security.Cryptography.Primitives Assembly Version: 6.0.0.0 Win32 Version: 6.0.121.56705 CodeBase: file:///C:/Program%20Files/dotnet/shared/Microsoft.NETCore.App/6.0.1/System.Security.Cryptography.Primitives.dll

System.Xml.ReaderWriter Assembly Version: 6.0.0.0 Win32 Version: 6.0.121.56705 CodeBase: file:///C:/Program%20Files/dotnet/shared/Microsoft.NETCore.App/6.0.1/System.Xml.ReaderWriter.dll

System.Private.Xml Assembly Version: 6.0.0.0 Win32 Version: 6.0.121.56705 CodeBase: file:///C:/Program%20Files/dotnet/shared/Microsoft.NETCore.App/6.0.1/System.Private.Xml.dll

System.Text.RegularExpressions Assembly Version: 6.0.0.0 Win32 Version: 6.0.121.56705 CodeBase: file:///C:/Program%20Files/dotnet/shared/Microsoft.NETCore.App/6.0.1/System.Text.RegularExpressions.dll

System.Net.WebClient Assembly Version: 6.0.0.0 Win32 Version: 6.0.121.56705 CodeBase: file:///C:/Program%20Files/dotnet/shared/Microsoft.NETCore.App/6.0.1/System.Net.WebClient.dll

System.Text.Encoding.Extensions Assembly Version: 6.0.0.0 Win32 Version: 6.0.121.56705 CodeBase: file:///C:/Program%20Files/dotnet/shared/Microsoft.NETCore.App/6.0.1/System.Text.Encoding.Extensions.dll

System.Runtime.Serialization.Formatters Assembly Version: 6.0.0.0 Win32 Version: 6.0.121.56705 CodeBase: file:///C:/Program%20Files/dotnet/shared/Microsoft.NETCore.App/6.0.1/System.Runtime.Serialization.Formatters.dll

System.Xml.XmlSerializer Assembly Version: 6.0.0.0 Win32 Version: 6.0.121.56705 CodeBase: file:///C:/Program%20Files/dotnet/shared/Microsoft.NETCore.App/6.0.1/System.Xml.XmlSerializer.dll

System.Runtime.CompilerServices.Unsafe Assembly Version: 6.0.0.0 Win32 Version: 6.0.121.56705 CodeBase: file:///C:/Program%20Files/dotnet/shared/Microsoft.NETCore.App/6.0.1/System.Runtime.CompilerServices.Unsafe.dll

System.Collections.Concurrent Assembly Version: 6.0.0.0 Win32 Version: 6.0.121.56705 CodeBase: file:///C:/Program%20Files/dotnet/shared/Microsoft.NETCore.App/6.0.1/System.Collections.Concurrent.dll

DataJuggler.Net6 Assembly Version: 6.0.0.0 Win32 Version: 6.0.0.0 CodeBase: file:///C:/Program%20Files%20(x86)/Data%20Juggler/DB%20Compare/DataJuggler.Net6.dll

System.Runtime.Loader Assembly Version: 6.0.0.0 Win32 Version: 6.0.121.56705 CodeBase: file:///C:/Program%20Files/dotnet/shared/Microsoft.NETCore.App/6.0.1/System.Runtime.Loader.dll

System.Diagnostics.StackTrace Assembly Version: 6.0.0.0 Win32 Version: 6.0.121.56705 CodeBase: file:///C:/Program%20Files/dotnet/shared/Microsoft.NETCore.App/6.0.1/System.Diagnostics.StackTrace.dll

System.Reflection.Metadata Assembly Version: 6.0.0.0 Win32 Version: 6.0.121.56705 CodeBase: file:///C:/Program%20Files/dotnet/shared/Microsoft.NETCore.App/6.0.1/System.Reflection.Metadata.dll

System.Collections.Immutable Assembly Version: 6.0.0.0 Win32 Version: 6.0.121.56705 CodeBase: file:///C:/Program%20Files/dotnet/shared/Microsoft.NETCore.App/6.0.1/System.Collections.Immutable.dll

** JIT Debugging **

Exception message:
Stack trace:

To reproduce

Include a complete code listing (or project/solution) that we can run to reproduce the issue.

Partial code listings, or multiple fragments of code, will slow down our response or cause us to push the issue back to you to provide code to reproduce the issue.

Console.WriteLine("Hello World!");

Expected behavior

A clear and concise description of what you expected to happen.

Further technical details

Microsoft.Data.SqlClient version: (found on the nuget or Microsoft.Data.SqlClient.dll) .NET target: (e.g. Framework 4.7.1, Core 2.2.2) SQL Server version: (e.g. SQL Server 2017) Operating system: (e.g. Windows 2019, Ubuntu 18.04, macOS 10.13, Docker container)

Additional context Add any other context about the problem here.

ErikEJ commented 2 years ago

Please share the .csproj of your main executable project

You must have a 3.0 reference somewhere...

DataJuggler commented 2 years ago

My project file is attached. Thank you for the fast response.

I looked all through the projects that are mine, I can't find anything.

Is there a way to force it to use 4.0, like a binding redirect? Switching from packages.config to project references is another thing I wouldn't have voted on.

I understand the benefit to updating if things work. I don't get paid to fix all these changes like salaried people do, but thanks none the less for trying to help.

I pasted my project file as a text document. Git Hub won't let me update the actual project file.

Thank you

DB Compare Project File As Text.txt

DataJuggler commented 2 years ago

I thought it was fixed when I found one of my Nuget packages had a reference to 3.0.0. I upgraded the package to use Microsoft.Data.SqlClient 4.0.0, published a new Nuget package, upgraded my reference, and still get the error.

Still checking, just wanted to come back and state that it wasn't fixed.

JRahnama commented 2 years ago

@DataJuggler I tried to clone your application from your GitHub repo , correct me if I have gone to a wrong repo. By just changing System.Data.SqlClient to Microsoft.Data.SfqlClient the application worked fine as a project. I did not try the installer or using the created nuget though. There might be referencing to other projects that have dependencies to version 3 of MDS?

Regarding the breaking change, we tried to avoid it for several years, but the security concern was going high. you can read more at this discussion here.

DataJuggler commented 2 years ago

The latest version is not checked in until I can fix this.

Not sure what TargetFramework the check in version is. It was just upgraded to 6.0.0, and Microsoft.Data.SqlClient 4.0.0

I can put a zip file on my server or somewhere else if you prefer.

The problem occurs when a method called Test Database Connection is called, if you don’t add encrypt=false. Short solution is I can just add it, but then I don’t see any benefit to your security upgrade.

Forcing SSL of SQL on people should have been an option, especially for non servers. If anyone is sniffing between my ATT Fiber Modem and my machine, I have bigger problems than SQL.

From: Javad @.> Sent: Friday, December 31, 2021 11:39 AM To: dotnet/SqlClient @.> Cc: Corby Nichols @.>; Mention @.> Subject: Re: [dotnet/SqlClient] Upgrade to 4.0, I get a message when the app runs in an installer can't find Microsoft.Data.SqlClient 3.0.0 (Issue #1448)

@DataJugglerhttps://github.com/DataJuggler I tried to clone your application from your GitHub repo https://github.com/DataJuggler/DBCompare , correct me if I have gone to a wrong repo. By just changing System.Data.SqlClient to Microsoft.Data.SfqlClient the application worked fine as a project. I did not try the installer or using the created nuget though. There might be referencing to other projects that have dependencies to version 3 of MDS?

Regarding the breaking change, we tried to avoid it for several years, but the security concern was going high. you can read more at this discussion herehttps://github.com/dotnet/SqlClient/pull/1210#issuecomment-898658021.

— Reply to this email directly, view it on GitHubhttps://github.com/dotnet/SqlClient/issues/1448#issuecomment-1003424881, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AGI4P7I65JGUGWR3ADEVIY3UTXTFBANCNFSM5LBM5ZTQ. Triage notifications on the go with GitHub Mobile for iOShttps://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Androidhttps://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub. You are receiving this because you were mentioned.Message ID: @.***>