System.TypeLoadException尝试实例化Google Speech客户端

时间:2018-09-13 04:11:54

标签: c# xamarin xamarin.android google-speech-api

我正在尝试实例化SpeechClient以在基于Xamarin的Android应用中使用Google的语音转文本API。

//credentialStream is a valid memory stream of the contents of my JSON file
var credential = GoogleCredential.FromStream(credentialStream);
Channel channel = new Channel(SpeechClient.DefaultEndpoint.Host, 
    SpeechClient.DefaultEndpoint.Port, 
    credential.ToChannelCredentials());
var speech = SpeechClient.Create(channel);

出现以下错误:

{System.TypeLoadException: Could not resolve type with token 0100003b (from typeref, class/assembly System.Runtime.Loader.AssemblyLoadContext, System.Runtime.Loader, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a)
  at Grpc.Core.GrpcEnvironment.AddRef () [0x00000] in <0d847ba1eabc48c599d358afb3f4b250>:0 
  at Grpc.Core.Channel..ctor (System.String target, Grpc.Core.ChannelCredentials credentials, System.Collections.Generic.IEnumerable`1[T] options) [0x00051] in <0d847ba1eabc48c599d358afb3f4b250>:0 
  at Grpc.Core.Channel..ctor (System.String host, System.Int32 port, Grpc.Core.ChannelCredentials credentials, System.Collections.Generic.IEnumerable`1[T] options) [0x00012] in <0d847ba1eabc48c599d358afb3f4b250>:0 
  at Grpc.Core.Channel..ctor (System.String host, System.Int32 port, Grpc.Core.ChannelCredentials credentials) [0x00000] in <0d847ba1eabc48c599d358afb3f4b250>:0 
  at Stoq.Droid.Models.Microphone.test (System.IO.Stream credentialStream) [0x00009] in C:\Users\Wesley\source\repos\Stoq\Stoq\Stoq.Android\Models\Microphone.cs:36 }

0 个答案:

没有答案