Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/257.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Google Cloud Vision API-创建Grpc.Core.Channel时出错_C#_Google Cloud Platform_Google Cloud Vision_Google Client - Fatal编程技术网

C# Google Cloud Vision API-创建Grpc.Core.Channel时出错

C# Google Cloud Vision API-创建Grpc.Core.Channel时出错,c#,google-cloud-platform,google-cloud-vision,google-client,C#,Google Cloud Platform,Google Cloud Vision,Google Client,我正在尝试使用Google Cloud Vision V1 Api的ImageAnnotatorClient类。我在下面的例子 创建(ServiceEndpoint、ImageAnnotatorSettings) 标题。我正在使用C#并试图构建一个经典的控制台应用程序。我使用的是Nuget的GRPC.Core版本1.15.0和Google.Cloud.Vision.V1版本1.2.0。我得到一个编译错误 “GoogleCredential”不包含的定义 “ToChannelCredentials

我正在尝试使用Google Cloud Vision V1 Api的ImageAnnotatorClient类。我在下面的例子

创建(ServiceEndpoint、ImageAnnotatorSettings)

标题。我正在使用C#并试图构建一个经典的控制台应用程序。我使用的是Nuget的GRPC.Core版本1.15.0和Google.Cloud.Vision.V1版本1.2.0。我得到一个编译错误

“GoogleCredential”不包含的定义 “ToChannelCredentials”和无扩展方法“ToChannelCredentials” 无法找到接受类型为“GoogleCredential”的第一个参数

以下是我的代码:

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);

有什么提示吗?

您可能缺少一条使用指令,特别是

using Grpc.Auth;
请参见
ToChannelCredentials
的定义作为扩展方法


检查您是否也包含了示例中存在的所有其他
使用
指令。

您可能缺少其中一个使用指令,特别是

using Grpc.Auth;
请参见
ToChannelCredentials
的定义作为扩展方法

使用示例中的
指令检查是否包含了所有其他