移动应用程序:使用;Microsoft.Azure.Cosmos“。netsdkv3中的Xamarin.Forms-跨平台

移动应用程序:使用;Microsoft.Azure.Cosmos“。netsdkv3中的Xamarin.Forms-跨平台,azure,xamarin,xamarin.forms,cosmos,Azure,Xamarin,Xamarin.forms,Cosmos,我使用Xamarin创建了一个小型移动应用程序。该应用程序使用Cosmos DB(Azure数据库)。我需要知道是否可以在Xamarin.forms中使用Microsoft.Azure.Cosmos(Nuget)。如果可能的话,你能帮我找出我做错了什么吗 我使用了Microsoft.Azure.DocumentDB.Core(v2.51) )。这是在azure-cosmos-dotnet-v2下。一切正常 今天,我尝试更新到Microsoft.Azure.Cosmos(v3.10)。这是在azu

我使用Xamarin创建了一个小型移动应用程序。该应用程序使用Cosmos DB(Azure数据库)。我需要知道是否可以在Xamarin.forms中使用Microsoft.Azure.Cosmos(Nuget)。如果可能的话,你能帮我找出我做错了什么吗

我使用了Microsoft.Azure.DocumentDB.Core(v2.51) )。这是在azure-cosmos-dotnet-v2下。一切正常

今天,我尝试更新到Microsoft.Azure.Cosmos(v3.10)。这是在azure-cosmos-dotnet-v3下。但当我点击CreateItemAsync这一行时,系统就失败了

CosmosClient client = new CosmosClient(CosmosEndpointUrl, CosmosAuthKey);
AccountProperties ap= await client.ReadAccountAsync(); // Check connection... It is OK
Database db = client.GetDatabase("MyDatabase");//My Database name is OK,
DatabaseResponse dbresponse= await db.ReadAsync();///Fail 
Container container = client.GetContainer("MyDatabase", "MyCollection");
dynamic testItem = new { id = "1234", userId = "2222", details = "it's working" };
ItemResponse<dynamic> response = await container.CreateItemAsync<dynamic>(testItem); /// Fail...



[0:] DocDBTrace Error: 0 : 
[0:] Operation will NOT be retried. Current attempt 0, Exception: System.NotSupportedException: Linked Away
  at System.Runtime.Remoting.Messaging.CallContext.LogicalGetData (System.String ) [0x00005] in <4b124141b7914f4d8253001e6b8a15cf>:0 
  at System.Diagnostics.CorrelationManager.get_ActivityId () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.14.0.110/src/Xamarin.iOS/mcs/class/referencesource/System/compmod/system/diagnostics/CorrelationManager.cs:23 
  at Microsoft.Azure.Cosmos.ActivityScope..ctor (System.Guid activityId) [0x0000c] in <36733228c2e04bedaa8ccf505865c0ea>:0 
  at Microsoft.Azure.Cosmos.Routing.ClientCollectionCache.ReadCollectionAsync (System.String collectionLink, System.Threading.CancellationToken cancellationToken, Microsoft.Azure.Cosmos.IDocumentClientRetryPolicy retryPolicyInstance) [0x000b8] in <36733228c2e04bedaa8ccf505865c0ea>:0 
  at Microsoft.Azure.Documents.BackoffRetryUtility`1[T].ExecuteRetryAsync (System.Func`1[TResult] callbackMethod, System.Func`3[T1,T2,TResult] callShouldRetry, System.Func`1[TResult] inBackoffAlternateCallbackMethod, System.TimeSpan minBackoffForInBackoffCallback, System.Threading.CancellationToken cancellationToken, System.Action`1[T] preRetryCallback) [0x0008c] in <5ffe0b54a2fb4f58adef177e11a3d996>:0  
**System.NotSupportedException:** 'Linked Away'
CosmosClient客户端=新的CosmosClient(CosmosEndpointUrl,CosmosAuthKey);
AccountProperties ap=await client.ReadAccountAsync();//检查连接。。。没关系
Database db=client.GetDatabase(“MyDatabase”)//我的数据库名还可以,
DatabaseResponse dbresponse=await db.ReadAsync()///失败
Container Container=client.GetContainer(“MyDatabase”、“MyCollection”);
DynamicTestItem=new{id=“1234”,userId=“2222”,details=“它正在工作”};
ItemResponse response=wait container.CreateItemAsync(testItem);//失败。。。
[0:]DocDBTrace错误:0:
[0:]操作将不会重试。当前尝试0,异常:System.NotSupportedException:已链接
0中的System.Runtime.Remoting.Messaging.CallContext.LogicalGetData(System.String)[0x00005]处
在/Library/Frameworks/Xamarin.iOS.framework/Versions/12.14.0.110/src/Xamarin.iOS/mcs/class/referencesource/System/compmod/System/Diagnostics/CorrelationManager.cs:23中的System.Diagnostics.CorrelationManager.get_ActivityId()[0x00000]
在Microsoft.Azure.Cosmos.ActivityScope..ctor(System.Guid activityId)[0x0000c]中:0
位于Microsoft.Azure.Cosmos.Routing.ClientCollectionCache.ReadCollectionAsync(System.String collectionLink,System.Threading.CancellationToken CancellationToken,Microsoft.Azure.Cosmos.IDocumentClientRetryPolicyInstance)[0x000b8]in:0
在Microsoft.Azure.Documents.BackoffRetryUtility`1[T].ExecuteTryAsync(System.Func`1[TResult]callbackMethod,System.Func`3[T1,T2,TResult]callShouldRetry,System.Func`1[TResult]inBackoffAlternateCallbackMethod,System.TimeSpan minBackoffForInBackoffCallback,System.Threading.CancellationToken CancellationToken,System.Action`1[T]0中的preRetryCallback)[0x0008c]
**System.NotSupportedException:*“已链接”

编辑:我添加了一些检查点,看起来连接正常(CosmosClient),但数据库连接不正确。

谢谢@magicandre1981。。。我正在接近解决这个问题。。。在Xamarin.Forms iOS属性中,我将“链接行为”从“仅链接框架SDK”更改为“不链接…”。。。我(在iOS中)解决了问题。。。你知道这一变化意味着什么吗?你从中得到的主要影响是你的包裹越来越大。根据您的应用程序和所使用的libs,这可能是一个小于1 MB的差异,但也可能增加到几十MB。只需检查您的应用程序并比较构建包,但如果删除了太多内容,则会出现异常。嘿@BlueOceans,您知道如何在不更改链接器行为的情况下解决此问题吗?谢谢@magicandre1981。。。我正在接近解决这个问题。。。在Xamarin.Forms iOS属性中,我将“链接行为”从“仅链接框架SDK”更改为“不链接…”。。。我(在iOS中)解决了问题。。。你知道这一变化意味着什么吗?你从中得到的主要影响是你的包裹越来越大。根据您的应用程序和所使用的libs,这可能是一个小于1 MB的差异,但也可能增加到几十MB。只需检查您的应用程序并比较构建包,但如果删除了太多内容,就会出现异常。嘿@BlueOceans,您是否找到了如何在不更改链接器行为的情况下修复此问题的方法?