在iPhone设备上尝试DatastoreDb.Create时遇到异常

时间:2019-03-10 06:40:07

标签: c# xamarin xamarin.ios grpc

我正在尝试使用DatastoreDb.Create()创建一个数据库,并在iPhone设备上运行该数据库时遇到异常。该代码在模拟器上运行正常。

这就是我想要做的:

private void SaveToDB()
    {
        try
        {
            // Your Google Cloud Platform project ID.
            string projectId = "xam-project";

            //We are storing movies. So this is a Movie kind. 
            string kind = "Country";

            //Create the datastore db
            var db = DatastoreDb.Create(projectId);

            Entity movieEntities = new Entity
            {
                Key = db.CreateKeyFactory(kind).CreateKey($"US"),
                ["CountryCode"] = "NZ",
                ["Name"] = "NewZeland"
            };

            using (var transction = db.BeginTransaction())
            {
                transction.Upsert(movieEntities);
                transction.Commit();
            }
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.Message);
        }
}

我遇到以下异常:

{System.ExecutionEngineException: Attempting to JIT compile method '(wrapper native-to-managed) Grpc.Core.Internal.NativeMetadataCredentialsPlugin:NativeMetadataInterceptorHandler (intptr,intptr,intptr,intptr,intptr,int)' while running in aot-only mode. See https://docs.microsoft.com/xamarin/ios/internals/limitations for more information.

 at (wrapper managed-to-native) System.Object.__icall_wrapper_mono_delegate_to_ftnptr(object)
at (wrapper managed-to-native) Grpc.Core.Internal.NativeMethods+DllImportsFromStaticLib.grpcsharp_metadata_credentials_create_from_plugin(Grpc.Core.Internal.NativeMetadataInterceptor)
at Grpc.Core.Internal.NativeMetadataCredentialsPlugin..ctor (Grpc.Core.AsyncAuthInterceptor interceptor) [0x0003b] in T:\src\github\grpc\src\csharp\Grpc.Core\Internal\NativeMetadataCredentialsPlugin.cs:47 
at Grpc.Core.MetadataCredentials.ToNativeCredentials () [0x00000] in T:\src\github\grpc\src\csharp\Grpc.Core\CallCredentials.cs:80 
at Grpc.Core.CompositeChannelCredentials.CreateNativeCredentials () [0x00000] in T:\src\github\grpc\src\csharp\Grpc.Core\ChannelCredentials.cs:202 
at Grpc.Core.ChannelCredentials.<.ctor>b__2_0 () [0x00000] in T:\src\github\grpc\src\csharp\Grpc.Core\ChannelCredentials.cs:45 
at System.Lazy`1[T].CreateValue () [0x00081] in <2b439461a53d406abf16d6e5e34ece7f>:0 
at System.Lazy`1[T].LazyInitValue () [0x00080] in <2b439461a53d406abf16d6e5e34ece7f>:0 
at System.Lazy`1[T].get_Value () [0x0003a] in <2b439461a53d406abf16d6e5e34ece7f>:0 
at Grpc.Core.ChannelCredentials.GetNativeCredentials () [0x00000] in T:\src\github\grpc\src\csharp\Grpc.Core\ChannelCredentials.cs:80 
at Grpc.Core.Channel..ctor (System.String target, Grpc.Core.ChannelCredentials credentials, System.Collections.Generic.IEnumerable`1[T] options) [0x0007e] in T:\src\github\grpc\src\csharp\Grpc.Core\Channel.cs:77 
at Grpc.Core.Channel..ctor (System.String host, System.Int32 port, Grpc.Core.ChannelCredentials credentials, System.Collections.Generic.IEnumerable`1[T] options) [0x00000] in T:\src\github\grpc\src\csharp\Grpc.Core\Channel.cs:109 
 at Google.Api.Gax.Grpc.ChannelPool.GetChannel (Google.Api.Gax.Grpc.ServiceEndpoint endpoint, Grpc.Core.ChannelCredentials credentials) [0x0003a] in C:\Users\skeet\Test\Projects\gax-dotnet\releasebuild\Google.Api.Gax.Grpc\ChannelPool.cs:127 
at Google.Api.Gax.Grpc.ChannelPool.GetChannel (Google.Api.Gax.Grpc.ServiceEndpoint endpoint) [0x0001d] in C:\Users\skeet\Test\Projects\gax-dotnet\releasebuild\Google.Api.Gax.Grpc\ChannelPool.cs:93 
at Google.Cloud.Datastore.V1.DatastoreClient.Create (Google.Api.Gax.Grpc.ServiceEndpoint endpoint, Google.Cloud.Datastore.V1.DatastoreSettings settings) [0x00000] in C:\Users\jon\Test\Projects\google-cloud-dotnet\releasebuild\apis\Google.Cloud.Datastore.V1\Google.Cloud.Datastore.V1\DatastoreClient.cs:399 
at Google.Cloud.Datastore.V1.DatastoreDb.Create (System.String projectId, System.String namespaceId, Google.Cloud.Datastore.V1.DatastoreClient client) [0x00000] in C:\Users\jon\Test\Projects\google-cloud-dotnet\releasebuild\apis\Google.Cloud.Datastore.V1\Google.Cloud.Datastore.V1\DatastoreDb.cs:84 
at Kudos.ViewController.SaveToDB () [0x0000c] in /Users/sandeepmahajan/Documents/Projects/sury-kudos/SuryKudos/SuryKudos/ViewController.cs:75 }

此行发生异常:

//Create the datastore db
var db = DatastoreDb.Create(projectId);

非常感谢您提出任何建议/解决方法。

0 个答案:

没有答案