-
Notifications
You must be signed in to change notification settings - Fork 299
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
Xamarin.Android - SqlClient connection broken since 5.1.1 #2251
Comments
@farlop can you verify 5.1.2 and 5.2.0-preview3 as well? |
I ran into this issue while trying to upgrade to 5.1.2
I will try with 5.2.0-preview3 as soon as possible
Enviado desde Outlook para Android<https://aka.ms/AAb9ysg>
…________________________________
From: DavoudEshtehari ***@***.***>
Sent: Thursday, November 30, 2023 8:13:35 PM
To: dotnet/SqlClient ***@***.***>
Cc: Andrés Valor ***@***.***>; Mention ***@***.***>
Subject: Re: [dotnet/SqlClient] Xamarin.Android - SqlClient connection broken since 5.1.1 (Issue #2251)
@farlop<https://github.com/farlop> can you verify 5.1.2 and 5.2.0-preview3 as well?
—
Reply to this email directly, view it on GitHub<#2251 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AAUNMHUFIAIGINSKFOQ3E63YHDLF7AVCNFSM6AAAAABABPGLEOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMZUGM4TQMZRGE>.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
Just tested in 5.2.0-preview3 with same results:
|
It seems that the problem may lie here Here a new MemoryCache instance is being created, but the namespace System.Runtime.Caching is not supported in monoandroid. From what I've read from other similar issues (here), a possible solution could be migrate to Microsoft.Extensions.Caching package. Or just handle this situation to avoid crashing in Xamarin Android |
Hi! Is there any advance on this issue? We are being pushed to update the library to avoid security bugs already fixed, but unable to do it due to this error |
@farlop We tried to reproduce the issue using MDS versions from 5.1.0, 5.1.1 and up to the latest. However, we are unable to reproduce the issue. Would you mind sharing the source code including the project file for your repro for us to investigate any further? |
I've created the following repository for the issue: https://github.com/farlop/SqlClientBugRepro2251 I'm sorry for not noticing before that reproducing the error was not quite straightforward, as the process involves loading assemblies dynamically. |
@farlop. Thank you for providing the reproduction source code. I noticed that you are using a custom loader for the MDS driver. I tried to replicate your repro using a MAUI app since Xamarin support will end on May 1, 2024. Also, I added a custom loader for MDS driver that targets .Net8.0. the runtime folder did get created in the published distribution. However, it also has the same issue of not loading the correct dll for Android. To fix that, I just copied the dll from the runtime/unix folder into the main folder of the published distribution. If you want to try this option, then in your custom loader, you may want to implement the detection of the platform and load the appropriate dll from the runtime folder as well. Lastly, since this issue is not directly related to MDS driver, but more in the way how it is used, we will now close this ticket. |
Thanks @arellegue for reviewing my repro and provide a detailed answer. I truly appreciate that. Unfortunately I don't fully agree with the arguments that justify the error. The problem of having the right assembly published (the one from runtime/Unix folder) is solved by using the RuntimeIdentifier in the publish profile. You can check that when adding that parameter with the Android value, the .ell published is 1,5Mb instead the few Kb version from NetStandard21 that just launched the not supported exception. The problem with 5.1.1 and beyond is that it introduced the use of MemoryCache from the System.Runtime.Caching namespace, which is not available at mono Android. I referenced that change on my previous comment from December (#2251 (comment)). Could a version 5.1.0.1 (for example) be released that just upgrades the dependency package to Axite.Identity that has that vulnerability? That would be a perfectly valid solution for us. If not, is there any chance that some code could be added to avoid referencing that unsupported class in monoandroid? I don't know it that scenario changes with .Net 8.0 and MAUI. I will give it a try, but unfortunately the migration to MAUI for the product is still an ongoing effort and we need to give support to customers, that are stopping the release. Thank you again for your attention |
Describe the bug
Until version 5.1.0, a Xamarin Forms application running in Android could connect to an SQL Server database directly.
When tried to upgrade to latest, I've found that some change in 5.1.1 is causing to fail. Reverting to 5.1.0 solves the problem.
Exceptions info:
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.
Expected behavior
Connection should be made and exception not be raised
Further technical details
Microsoft.Data.SqlClient version: 5.1.1
.NET target: Xamarin Forms
SQL Server version: SQL Server 2017
Operating system: Android
The text was updated successfully, but these errors were encountered: