-
Notifications
You must be signed in to change notification settings - Fork 292
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
Mono: System.TypeInitializationException: The type initializer for 'Microsoft.Data.SqlClient.InOutOfProcHelper' #1263
Comments
This is fixed in 4.0.0 preview with #1120 Can you give the preview a try and see if that resolves your issue please. |
@lillo42 thanks for bringing this up. As @Wraith2 mentioned we fixed this issue in our latest preview release 4.0.0-preview1.21237.2. Can you try and let us know if the issue is resolved please? |
I've update to 4.0.0-preview1.21237.2, but I'm getting this error:
|
The code MonoCrash.zip |
After upgrading to the v4 preview package, I tried again (see description in #1120). After disabling shadow copy to make sure that
So I ran the tests again with mono debug logs:
Of course! The Now the question is: why does the SNI initialization code path is triggered on Mono running Linux/macOS? I guess it's not triggered at all on .NET Core running Linux/macOS, am I right? |
Are you compiling against against a windows target and copying the files to a linux host? That's the only way I can think of that you'd get an implementation that tries to use the windows dlls on a linux system, the linux assemblies force managed sni. |
I don't copy any files manually. Here's what I'm doing, i.e. running a unit test targeting
And here are some relevant stack traces resulting from using
You can get the full stack traces in the TestResults-Linux file the that just ran on GitHub actions. Note that running the same unit test on
|
When using net5.0, please turn off |
@lillo42 I was getting the exception as you mentioned for both version: 3.0.0 and 4.0.0 preview when I was not using the .net framework image along with Mono. Here is the gist (Windows + .net472 +mono) that is using latest Microsoft.Data.SqlClient and is opening connection successfully. |
@Kaur-Parminder can you try to run using .NET Framework with mono on Linux? |
Here is one for Linux container with .netcore 3.1 and mono https://gist.github.com/Kaur-Parminder/92b92ef2152ba3dcbdb168e4983a1e2c |
@Kaur-Parminder in your last sample did you build the project using .NET Framework or .NET Core? |
I have used .NetCore with Linux. |
@Kaur-Parminder Yes, see this gist: https://gist.github.com/arhughes/8b15d7ee88da250cc4492814cac6db52 |
@lillo42 I see the error when target is set to net 48 and net 471. Dlls seems are not being loaded correctly although they are present in the bin folder. I have not been able to find way to Debug the issue through VS docker-compose for Linux container (.netframeowrk projects is only debuggable with Windows container). We have to look into it further. I see System.Data and System.Data.Sqlclient are able to open connection successfully but not Microsoft.Data.SqlClient. |
@cheenamalhotra Any update here? There's a repro available and the recommended workaround seems to be to disable encryption, which seems unacceptable for some customers? |
The netfx implementation requires an unmanaged component to implement network connectivity. That implementaion is closed source non-portable and not provided for non-windows platforms. In the cases above people are restoring the netfx implementation and trying to use it on linux and that won't work. If you want to run the code on linux you need to use the correct platform implementation assembly. |
Error to connect on SQL Server using Microsoft.Data.SqlClient with Mono on linux.
To reproduce
Gist: https://gist.github.com/arhughes/8b15d7ee88da250cc4492814cac6db52
Expected behavior
Connect to the database.
Further technical details
Microsoft.Data.SqlClient version: 3.0.0
.NET target: Mono with .NET Framework 4.7.1
SQL Server version: SQL Server 2017
Operating system: Docker container - Linux
Additional context
Reported: fluentmigrator/fluentmigrator#1483
The text was updated successfully, but these errors were encountered: