Replies: 2 comments 2 replies
-
Beta Was this translation helpful? Give feedback.
-
if this is still open (which I doubt). Disclaimer: Officially afaik, it's not supported, so I wouldn't recommend. For basic SqlClient functionality with trimming or aot, based on my experience you need
a) on linux: <linker>
<assembly fullname="System.Configuration.ConfigurationManager">
<type fullname="System.Configuration.ClientConfigurationHost" preserve="all"/>
</assembly>
</linker>
Note: this is optional. If you don't do this, the application will internally throw exceptions (which will be caught by the sqlclient code), but it will work. b) on windows ( <linker>
<assembly fullname="System.Configuration.ConfigurationManager">
<type fullname="System.Configuration.ClientConfigurationHost" preserve="all"/>
</assembly>
<assembly fullname="System.Private.CoreLib">
<type fullname="System.StubHelpers.InterfaceMarshaler" preserve="all"/>
</assembly>
</linker> (on windows it does use the SNI dll) Note: I didn't play around with the "preserve=all". I only got rid of exceptions. I use SqlClient and trimmed and aot builds on linux-x64, not in production, with SqlConnection/SqlCommand and basic auth (with TLS). You will get (handled) exceptions: System.NullReferenceException at Microsoft.Data.SqlClient.SqlClientEventSource.OnEventCommand |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I understand MS.Data.SqlClient does not support trimming yet.
Could the team share a build configuration that works in .NET 8.0 to include SqlClient untrimmed into an exe that is otherwise trimmed?
My goal is to publish a CLI tool that is self-contained -- and obviously trimmed for size.
Since I updated to latest MS.Data.SqlClient and .NET 8.0, no configuration I tried to exclude SqlClient from trimming works.
The only setup that works is completely disabling trimming, and insead of being ~30Mo the self-contained executable is ~180Mo now. That's terrible for a CLI tool.
Most things I tried usually end up in a TypeLoadException with "Unable to load DLL 'Microsoft.Data.SqlClient.SNI.dll'".
Beta Was this translation helpful? Give feedback.
All reactions