如何解决C#中的“加载本机库错误。在任何可能的位置找不到”错误?

时间:2019-01-22 16:21:47

标签: c# visual-studio text-to-speech grpc

我正在实现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

0 个答案:

没有答案