You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
I would like to use Microsoft.Azure.Cosmos in a native AOT'd application. However, it is not currently possible.
C:\Users\eerhardt\.nuget\packages\microsoft.azure.cosmos\3.38.1\lib\netstandard2.0\Microsoft.Azure.Cosmos.Client.dll : warning IL2104: Assembly 'Microsoft.Azure.Cosmos.Client' produced trim warnings. For more information see https://aka.ms/dotnet-illink/libraries [C:\Users\eerhardt\source\repos\AspireApp15\AspireApp15.ApiService\AspireApp15.ApiService.csproj]
ILC : warning IL3000: Microsoft.Azure.Documents.ServiceInteropWrapper.CheckIfAssembliesExist(String&): 'System.Reflection.Assembly.Location.get' always returns an empty string for assemblies embedded in a single-file app. If the path to the app directory is needed, consider calling 'System.AppContext.BaseDirectory'. [C:\Users\eerhardt\source\repos\AspireApp15\AspireApp15.ApiService\AspireApp15.ApiService.csproj]
ILC : warning IL3000: Microsoft.Azure.Documents.ServiceInteropWrapper.CheckIfAssembliesExist(String&): 'System.Reflection.Assembly.Location.get' always returns an empty string for assemblies embedded in a single-file app. If the path to the app directory is needed, consider calling 'System.AppContext.BaseDirectory'. [C:\Users\eerhardt\source\repos\AspireApp15\AspireApp15.ApiService\AspireApp15.ApiService.csproj]
C:\Users\eerhardt\.nuget\packages\system.configuration.configurationmanager\6.0.0\lib\net6.0\System.Configuration.ConfigurationManager.dll : warningIL2104: Assembly 'System.Configuration.ConfigurationManager' produced trim warnings. For more information see https://aka.ms/dotnet-illink/libraries[C:\Users\eerhardt\source\repos\AspireApp15\AspireApp15.ApiService\AspireApp15.ApiService.csproj]
C:\Users\eerhardt\.nuget\packages\newtonsoft.json\10.0.2\lib\netstandard1.3\Newtonsoft.Json.dll : warning IL2104: Assembly 'Newtonsoft.Json' produced trim warnings. For more information see https://aka.ms/dotnet-illink/libraries [C:\Users\eerhardt\source\repos\AspireApp15\AspireApp15.ApiService\AspireApp15.ApiService.csproj]
C:\Users\eerhardt\.nuget\packages\newtonsoft.json\10.0.2\lib\netstandard1.3\Newtonsoft.Json.dll : warning IL3053: Assembly 'Newtonsoft.Json' produced AOT analysis warnings. [C:\Users\eerhardt\source\repos\AspireApp15\AspireApp15.ApiService\AspireApp15.ApiService.csproj]
C:\Users\eerhardt\.nuget\packages\runtime.win-x64.microsoft.dotnet.ilcompiler\8.0.2\framework\System.Linq.Expressions.dll : warning IL3053: Assembly'System.Linq.Expressions' produced AOT analysis warnings. [C:\Users\eerhardt\source\repos\AspireApp15\AspireApp15.ApiService\AspireApp15.ApiService.csproj]
C:\Users\eerhardt\.nuget\packages\runtime.win-x64.microsoft.dotnet.ilcompiler\8.0.2\framework\Microsoft.CSharp.dll : warning IL3053: Assembly 'Microsoft.CSharp' produced AOT analysis warnings. [C:\Users\eerhardt\source\repos\AspireApp15\AspireApp15.ApiService\AspireApp15.ApiService.csproj]
C:\Users\eerhardt\.nuget\packages\microsoft.azure.cosmos\3.38.1\lib\netstandard2.0\Microsoft.Azure.Cosmos.Direct.dll : warning IL2104: Assembly 'Microsoft.Azure.Cosmos.Direct' produced trim warnings. For more information see https://aka.ms/dotnet-illink/libraries [C:\Users\eerhardt\source\repos\AspireApp15\AspireApp15.ApiService\AspireApp15.ApiService.csproj]
C:\Users\eerhardt\.nuget\packages\microsoft.azure.cosmos\3.38.1\lib\netstandard2.0\Microsoft.Azure.Cosmos.Direct.dll : warning IL3053: Assembly 'Microsoft.Azure.Cosmos.Direct' produced AOT analysis warnings. [C:\Users\eerhardt\source\repos\AspireApp15\AspireApp15.ApiService\AspireApp15.ApiService.csproj]
When I try to run the produced executable the first error I hit is:
Unhandled Exception: System.Configuration.ConfigurationErrorsException: Configuration system failed to initialize
---> System.MissingMethodException: No parameterless constructor defined for type 'System.Configuration.ClientConfigurationHost'.
at System.ActivatorImplementation.CreateInstance(Type, Boolean) + 0x119
at System.Configuration.Internal.ConfigSystem.System.Configuration.Internal.IConfigSystem.Init(Type, Object[]) + 0x43
at System.Configuration.ClientConfigurationSystem..ctor() + 0x47
at System.Configuration.ConfigurationManager.EnsureConfigurationSystem() + 0x56
--- End of inner exception stack trace ---
at System.Configuration.ConfigurationManager.EnsureConfigurationSystem() + 0xea
at System.Configuration.ConfigurationManager.PrepareConfigSystem() + 0x12
at System.Configuration.ConfigurationManager.GetSection(String) + 0x18
at System.Configuration.ConfigurationManager.get_AppSettings() + 0x11
at Microsoft.Azure.Cosmos.DocumentClient.Initialize(Uri, ConnectionPolicy, Nullable`1, HttpMessageHandler, ISessionContainer, Nullable`1, IStoreClientFactory, TokenCredential, String, RemoteCertificateValidationCallback, CosmosClientTelemetryOptions) + 0x1bd
at Microsoft.Azure.Cosmos.DocumentClient..ctor(Uri, AuthorizationTokenProvider, EventHandler`1, ConnectionPolicy, Nullable`1, JsonSerializerSettings, ApiType, EventHandler`1, HttpMessageHandler, ISessionContainer, Nullable`1, Func`2, IStoreClientFactory, Boolean, String, RemoteCertificateValidationCallback, CosmosClientTelemetryOptions, IChaosInterceptorFactory) + 0x1fd
at Microsoft.Azure.Cosmos.ClientContextCore.Create(CosmosClient, CosmosClientOptions) + 0x1bd
at Microsoft.Azure.Cosmos.CosmosClient..ctor(String, AuthorizationTokenProvider, CosmosClientOptions) + 0x10e
at Microsoft.Extensions.Hosting.AspireMicrosoftAzureCosmosDBExtensions.<>c__DisplayClass3_0.<AddAzureCosmosDB>g__ConfigureDb|3() + 0xc3
Note that Newtonsoft.Json is not currently AOT compatible (and looks likely it will never be). See JamesNK/Newtonsoft.Json#2732. The only JSON object serialization and deserialization that works with native AOT is the System.Text.Json source generator. Or else you need to use the reader/writer APIs or JsonDocument/JsonNode APIs.
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe.
I would like to use
Microsoft.Azure.Cosmos
in a native AOT'd application. However, it is not currently possible.Describe the solution you'd like
Make
Microsoft.Azure.Cosmos
compatible with native AOT. See https://devblogs.microsoft.com/dotnet/creating-aot-compatible-libraries/ for instructions/tips for how to do this. We should drive the warnings to 0.Describe alternatives you've considered
N/A
Additional context
When I publish an app that has the following code:
I get the following warnings:
When I try to run the produced executable the first error I hit is:
Note that Newtonsoft.Json is not currently AOT compatible (and looks likely it will never be). See JamesNK/Newtonsoft.Json#2732. The only JSON object serialization and deserialization that works with native AOT is the System.Text.Json source generator. Or else you need to use the reader/writer APIs or JsonDocument/JsonNode APIs.
The text was updated successfully, but these errors were encountered: