1

I want to know whether there is a nuget package that contains GetSheetService(), I can't find which is the right package, anyone know this? Has anyone used this method?

This are the packages that I had installed:

  <ItemGroup>
    <PackageReference Include="Google.Apis" Version="1.40.3" />
    <PackageReference Include="Google.Apis.Auth" Version="1.40.3" />
    <PackageReference Include="Google.Apis.Auth.Mvc" Version="1.40.3" />
    <PackageReference Include="Google.Apis.Sheets.v4" Version="1.40.3.1694" />
    <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.28" />
  </ItemGroup>

and this is the problem I have encountered: enter image description here

this is the start of the cs file:

using System;
using System.IO;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Http;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging;
using Google.Apis.Sheets.v4;
Linda Lawton - DaImTo
  • 106,405
  • 32
  • 180
  • 449
Cindy Pau
  • 13,085
  • 1
  • 15
  • 27
  • That's a method in the current class. Please explain your scenario. That method doesn't exist in the Sheets package. Did you copy some code from elsewhere? Then copy along the relevant methods. – CodeCaster Sep 03 '19 at 05:50
  • @CodeCaster This is actually part of someone else's problem, I know azure function. But the question he asked about has some Google API issues, I don't understand this. It’s just that I am very curious about this. I would be very grateful if anyone could give some help!I googled, but can't find the current package. – Cindy Pau Sep 03 '19 at 06:02
  • This is the questions: https://stackoverflow.com/questions/57762233/azure-functions-the-given-assembly-name-or-codebase-was-invalid-exception-fr/57764480#57764480 – Cindy Pau Sep 03 '19 at 06:04
  • @CodeCaster Can you solve his problem? I am a newcomer to Google API. – Cindy Pau Sep 03 '19 at 06:06

1 Answers1

1

The google .net client library does not have a method called get sheets service. I suspect you are copying this from someones code some places. The correct way to create a sheets service follows

/// <summary>
    /// This method get a valid service
    /// </summary>
    /// <param name="credential">Authecated user credentail</param>
    /// <returns>SheetsService used to make requests against the Sheets API</returns>
    private static SheetsService GetService(UserCredential credential)
    {
        try
        {
            if (credential == null)
                throw new ArgumentNullException("credential");

            // Create Sheets API service.
            return new SheetsService(new BaseClientService.Initializer()
            {
                HttpClientInitializer = credential,
                ApplicationName = "Sheets Oauth2 Authentication Sample"
            });
        }
        catch (Exception ex)
        {
            throw new Exception("Get Sheets service failed.", ex);
        }
    }
}

Code ripped from my google .net client Library sample project. Oauth2Authentication.cs)

Linda Lawton - DaImTo
  • 106,405
  • 32
  • 180
  • 449