我在Asp.net MVC 5中有一个使用Google Apis的网站。
有时,应用程序抛出一个Keyset由于未知原因而不存在:
这是我的代码:
var cert = new X509Certificate2(file, "notasecret",
X509KeyStorageFlags.MachineKeySet |
X509KeyStorageFlags.Exportable |
X509KeyStorageFlags.PersistKeySet);
var credential = new ServiceAccountCredential(
new ServiceAccountCredential.Initializer(googleCredential.ClientId)
{
Scopes = scopes
}.FromCertificate(cert));
_service = new CalendarService(new BaseClientService.Initializer
{
HttpClientInitializer = credential,
ApplicationName = "AppName"
});
有关如何解决此问题的任何想法吗?