c# - 如何修复 C# 中的“加载本机库时出错。在任何可能的位置都找不到”错误?
问题描述
我正在实现 Google Text-to-Speech API,我需要使用Channel
该类将凭据放入其中。
但是当我执行该credential.ToChannelCredentials()
方法时,会Error loading native library. Not found in any of the possible locations
出现错误
我查看了错误抛出给我的路径,我确认该方法尝试到达grpc_csharp_ext.x86.dll
项目 bin 文件夹中的 de,但文件位于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
解决方案
推荐阅读
- java - 位图未添加到列表对象 onPostExecute
- node.js - 如果流中未指定类型,是否可以强制编译失败?
- python - 为什么我的列表没有被 python 覆盖?
- java - 读取实时数据库节点
- python - 将 Python 字符串与 HTML 结合使用
- javascript - 如何将自定义 td 附加到从二维数组生成的表中?
- scheme - 如何从列表中提取和返回变量?
- mysql - 如何设置触发器以将 user_id 复制到另一个表
- user-agent - 如果用户日志指示没有用户代理,这意味着什么?
- java - selectionSort 方法,将按类型对 ArrayList 进行排序