【发布时间】:2016-08-25 01:19:02
【问题描述】:
我正在尝试加载包含访问Google Calendar API 的密钥的文件。 Following this tutorial.
为此,我创建了以下代码:
var certificate = new X509Certificate2("client_secret.json", "notasecret", X509KeyStorageFlags.Exportable);
我已经在我的解决方案中上传了client_secret.json 文件,这是文件的路径:"...\Visual Studio 2015\Projects\Calendar\Calendar\bin\Debug\client_secret.json"
但似乎代码找不到文件并返回此错误:
X509Certificate2 找不到指定的对象
我还在要读取的文件上设置Copy in the output directory 上的属性Always copy。
【问题讨论】:
-
您是否尝试为密钥添加完整路径?
-
@MegaTron 是的,同样的错误。我试着把它放在`c:`
-
好的,它是 Web(ASP) 应用程序吗?
-
@MegaTron 不是 wpf + c# 应用程序
-
@Dillinger 您确定该文件包含有效证书吗?
标签: c# x509certificate2