我的应用程序尝试通过Google云端硬盘进行身份验证时,出现异常/冲突。在我们的开发系统上,它运行良好。在我们的接受环境中,将记录异常。
(System.InvalidCastException: Unable to cast object of type 'System.Configuration.Internal.ConfigurationManagerInternal' to type 'System.Configuration.SR'.
at Formlogic.GoogleEnterpriseDrive.Library.GoogleDrive.Authenticate(String serviceAccountCertificate, String serviceAccountName) in C:\Sources\GoogleEnterpriseDrive\GoogleEnterpriseDriveLibrary\GoogleDrive.cs:line 122
at FormLogic.GoogleEnterpriseDrive.Lasernet.Input.GoogleEnterpriseDriveInput.OnJobsReceived(String moduleName, ConfigurationObject configuration, JobContext jobContext) in C:\Sources\GoogleEnterpriseDrive\GoogleEnterpriseDriveInput\GoogleEnterpriseDriveInput.cs:line 51
在两个系统上都检查了.NET版本,DLL和文件版本。这些是相同的。
GED_logging.job("GED GoogleDrive serviceAccountCertificate : " + serviceAccountCertificate);
GED_logging.job("GED GoogleDrive serviceAccountName : " + serviceAccountName);
try
{
GED_logging.job("GED GoogleDrive service account authentication request");
X509Certificate2 certificate = new X509Certificate2(serviceAccountCertificate, "notasecret", X509KeyStorageFlags.Exportable);
GED_serviceAccount = new ServiceAccountCredential(new Google.Apis.Auth.OAuth2.ServiceAccountCredential.Initializer(serviceAccountName)
{
Scopes = new[] { Google.Apis.Drive.v3.DriveService.Scope.Drive },
User = GED_User
}.FromCertificate(certificate));
GED_logging.job("GED GoogleDrive service account authentication obtained");
}
}
catch (Exception e)
{
GED_logging.error("GED GoogleDrive initialization could not authenticate service account");
throw e;
}