我正在实现Google Text-to-Speech API,我需要使用Channel
类将凭据放入其中。
但是当我执行credential.ToChannelCredentials()
方法时,会出现错误Error loading native library. Not found in any of the possible locations
我查看了错误抛出的路径,并证实该方法尝试到达项目bin文件夹中的de grpc_csharp_ext.x86.dll
,但文件位于C:\Users\<user>\.nuget\packages\grpc.core\1.18.0\runtimes\win\native
为了进行测试,我试图直接从该路径中将文件复制到bin中,并且可以正常工作,但是我知道那是不对的
我的代码:
var credential = GoogleCredential.FromFile(MyJSON).CreateScoped(TextToSpeechClient.DefaultScopes);
var channel = new Channel(TextToSpeechClient.DefaultEndpoint.ToString(), credential.ToChannelCredentials()); // trow the error here
TextToSpeechClient client = TextToSpeechClient.Create(channel);
我希望程序获取.dll的正确路径,但是正试图从我项目的文件夹bin中获取
grpc.core
版本 1.18.0