-
Notifications
You must be signed in to change notification settings - Fork 300
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
SqlClient doesn't work with Native AOT on windows #1941
Comments
I don't know if AOT support is a scenario that is on the roadmap. I'm sure it would be nice but it's quite a complex task. |
Are we speaking of async/mars level of complexity (3+ years) or something a bit more optimistic? |
Unknown. Without knowing what the blocking factors are I'd be guessing. The complexity that I can see comes from the way that you have to work out what can or cannot be trimmed, try it and see if it works. I also don't know if it's a goal for the MS team. While we can likely make it work from community contributions only the speed it limited. |
Doing following steps:
using this code
then
Given that your error indicates that Microsoft.Data.SqlClient.SNI.dll is probably missign, it's possible that you copy only EXE file without native Microsoft.Data.SqlClient.SNI.dll |
@kant2002 the resulting binary is in |
@vonzshik thats wrong location. Technically that’s executable but that’s not all what is needed for running NativeAOT application. You should look at |
@kant2002 yeah, I just realized that. I was expecting a single binary, but I guess SqlClient is a bit different in this regard. I'm closing this issue since everything works and I just was looking at the wrong folder. |
Unless we've managed to run the entire test suite in AOT mode I would hesitate to say that it's aot compatible. There's a lot of code this example doesn't touch. Bulk Copy, AE, etc. If we want to be able to say that it's compatible we need to test exhaustively. |
Oh, it's definitely not AOT compatible (there were quite a few trimming warnings and the resulting binary size leaves to be desired). Nevertheless, the basic scenario works (which is what this issue is about). Anything else I would have solved on case by case scenario, though that's up to the maintainers. |
With this change you can shave 900Kb out of 25.8Mb from sample SqlClient app from here dotnet/SqlClient#1941 (comment) Other example is that usage of `System.Runtime.Caching.MemoryCache` as shown in https://learn.microsoft.com/en-us/dotnet/api/system.runtime.caching.memorycache Applying configuration switch reduce app size by 5.2Mb (from 7.8Mb to 2.6Mb) Most likely modern applications which are first to use NativeAOT would not need this functionality because they use other means for configuration, so would be great to have this disabled. Low drop in size in SqlClient coming from fact that there other large dependencies which keep Xml related code around.
Given a small hello world example:
throws on windows with Native AOT:
Works fine on linux (ubuntu wsl). Would have been nice if SqlClient supported Native AOT on windows.
Also, the resulting binary on linux is about 45mb, but that's a different issue altogether.
.NET 7.0.3, SqlClient 5.1.0.
The text was updated successfully, but these errors were encountered: