我正在使用Google BigQuery将数据从文件传输到BigQuery。我正在使用BigQuery Google.Cloud.BigQuery.V2版本=“ 1.3.0”及其依赖的dll。我的C#代码在ConsoleApplication VS2019中工作正常,但是当我使用SSIS任务时,出现错误:
System.MissingMethodException:找不到方法:“ Google.Apis.Auth.OAuth2.GoogleCredential Google.Api.Gax.Rest.ScopedCredentialProvider.GetCredentials(Google.Apis.Auth.OAuth2.GoogleCredential)”。在Google.Cloud.BigQuery.V2.BigQueryClient.Create(字符串projectId,GoogleCredential凭据)
var googlecredential = new GoogleCredentials()
{
private_key = "",
client_email = "",
type = ""
};
var credentials = GoogleCredential.FromJson(JsonConvert.SerializeObject(googlecredential));
BigQueryClient client = BigQueryClient.Create(projectId, credentials); -> this line throws error if I'm referencing dll Google.Cloud.BigQuery.V2 version 1.3 or 1.4 and it works if for 1.2 version.
注意:此错误仅在脚本任务中发生。所有Dll在GAC中注册。
我有同样的问题。最后,我通过使用BigqueryService而不是BigQueryClient解决了它。
var service = new BigqueryService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = "CS Bigquery"
});
我使用的完整样本在这里:https://www.codeproject.com/Tips/785554/Google-BigQuery-API-Client-Sample-Code-for-Csharp