W509Certificate2 参考缺失

Gre*_*reg 1 .net c# google-drive-api

我正在尝试让 Google Drive API 使用此处所述的委托服务帐户方法。我遇到的问题是这一行我应该创建一个 X509Certificate 对象:

X509Certificate2 certificate = new X509Certificate2(SERVICE_ACCOUNT_PKCS12_FILE_PATH, "notasecret",
            X509KeyStorageFlags.Exportable);
Run Code Online (Sandbox Code Playgroud)

但是,编译器告诉我,“找不到类型或命名空间名称 X509Certificate2”。我正在使用System.Security.Cryptograpyand System.Security.Cryptography.X509Certificates,根据文档,它应该包含 X509Certificate2 类。问题是,我的由于某种原因没有。它有 X509Certificate,但这不适用于上面的示例。我尝试过.net v4.5和4。

Nib*_*Pig 5

X509Certificate2存在于System.Security.Cryptography.X509CertificatesSystem.dll,因此其他引用可能会干扰它,或者可能存在 dll 版本错误的问题。