Tho*_*mas 0 c# google-client google-cloud-platform google-cloud-vision
我正在尝试使用Google Cloud Vision V1 Api的ImageAnnotatorClient类。我正在https://googleapis.github.io/google-cloud-dotnet/docs/Google.Cloud.Vision.V1/api/Google.Cloud.Vision.V1.ImageAnnotatorClient.html下的示例中
创建(ServiceEndpoint,ImageAnnotatorSettings)
标头。我正在使用C#并尝试构建经典的控制台应用程序。我正在使用来自Nuget的GRPC.Core版本1.15.0和Google.Cloud.Vision.V1版本1.2.0。我收到一个编译错误
“ GoogleCredential”不包含“ ToChannelCredentials”的定义,也找不到包含“ GoogleCredential”类型的第一个参数的扩展方法“ ToChannelCredentials”
下面是我的代码:
GoogleCredential credential = GoogleCredential
.FromFile(@"C:\Users\...\12345.json")
.CreateScoped(ImageAnnotatorClient.DefaultScopes);
Google.Cloud.Vision.V1.Image image1 = Google.Cloud.Vision.V1.Image.FromFile(@"c:\Users\....\Image14b.png");
Channel channel = new Channel(
ImageAnnotatorClient.DefaultEndpoint.Host, ImageAnnotatorClient.DefaultEndpoint.Port, credential.ToChannelCredentials());
ImageAnnotatorClient client = ImageAnnotatorClient.Create(channel);
IReadOnlyList<EntityAnnotation> textAnnotations = client.DetectText(image1);
Run Code Online (Sandbox Code Playgroud)
我在下面的行出现错误:
Channel channel = new Channel(
ImageAnnotatorClient.DefaultEndpoint.Host, ImageAnnotatorClient.DefaultEndpoint.Port, credential.ToChannelCredentials());
Run Code Online (Sandbox Code Playgroud)
有什么提示吗?
您可能会丢失其中一个using指令,特别是
using Grpc.Auth;
Run Code Online (Sandbox Code Playgroud)
请参见此处ToChannelCredentials作为扩展方法的定义。
检查您是否还包括using了样本中存在的所有其他指令。
| 归档时间: |
|
| 查看次数: |
258 次 |
| 最近记录: |