Hello,
i'm not expert but do you add the permission INTERNET in the manifest ?
I suppose yes but you need to ACCEPT on run time
Xamarin App using Azure Cosmos DB Won't Connect on Device
Our very simple Xamarin App that connects to an Azure Cosmos DB and it works fine in Debug and Release configs on the emulators. When we deploy to a device (or to TestFlight) it crashes on the attempt to connect to the Azure Cosmos DB. The error is a simple "Method not found" which is really strange.
The app uses Microsoft.Azure.CosmosDB NuGet package v 3.22.1
This is the simple code block on initialization
public async Task ConnectCloudDB()
{
try
{
cosmosClient = new CosmosClient(AppConfig.EndpointUri, AppConfig.PrimaryKey, new CosmosClientOptions() { ApplicationName = "MySimpleApp" });
database = await cosmosClient.CreateDatabaseIfNotExistsAsync(databaseId);
container = await database.CreateContainerIfNotExistsAsync(containerId, "/partitionKey");
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
}
The error occurs on the first line of the function, new CosmosClient
This is the full error text
The error I get is {System.MissingMethodException: Method not found: Microsoft.Azure.Cosmos.Core.Utf8.Utf8Span Microsoft.Azure.Cosmos.Core.Utf8.Utf8Span.UnsafeFromUtf8BytesNoValidation(System.ReadOnlySpan`1<byte>)
at Microsoft.Azure.Cosmos.Tracing.TraceData.ClientConfigurationTraceDatum.GetSerializedDatum () <0x12d1809a8 + 0x00028> in <52e81403ebce4034958e1bd4a74f9405>:0
at Microsoft.Azure.Cosmos.Tracing.TraceData.ClientConfigurationTraceDatum..ctor (Microsoft.Azure.Cosmos.CosmosClientContext cosmosClientContext, System.DateTime startTime) <0x12ccc3798 + 0x00166> in <52e81403ebce4034958e1bd4a74f9405>:0
at Microsoft.Azure.Cosmos.CosmosClient..ctor (System.String accountEndpoint, Microsoft.Azure.Cosmos.AuthorizationTokenProvider authorizationTokenProvider, Microsoft.Azure.Cosmos.CosmosClientOptions clientOptions) <0x12cb298f8 + 0x000a0> in <52e81403ebce4034958e1bd4a74f9405>:0
at Microsoft.Azure.Cosmos.CosmosClient..ctor (System.String accountEndpoint, System.String authKeyOrResourceToken, Microsoft.Azure.Cosmos.CosmosClientOptions clientOptions) <0x12cb1e628 + 0x00014> in <52e81403ebce4034958e1bd4a74f9405>:0
at UIPlayground.MainPage.ConnectCloudDB () [0x00027] in C:\Users\drewm\source\repos\UIPlayground\UIPlayground\UIPlayground\MainPage.xaml.cs:117 }
Again, it is very strange since it works perfectly on emulators, but says "method not found" when on the device itself. Any help would be greatly appreciated!
Xamarin
Azure Cosmos DB
1 answer
Sort by: Most helpful
-
cristopheB 551 Reputation points
2021-11-09T15:29:38.68+00:00