从资源 visual basic 导入 X509Certificates

import X509Certificates from resource visual basic

 Dim x509Store As New X509Store(StoreName.Root, StoreLocation.CurrentUser)
    Dim cert = My.Resources.Facebook_com
    x509Store.Open(OpenFlags.MaxAllowed)
    x509Store.Add(cert)
    x509Store.Close()

x509Store.Add(cert) 行中的问题显示此错误 "value of type '1-dimensional array of byte' cannot be converted to system.cryptography.x509certificats.x509certificats2"

您从资源中获取的数据是一个字节数组。

您应该先将其转换为证书对象。

你可以试试这个:

Sub Main()
    Dim x509Store As New X509Store(StoreName.Root, StoreLocation.CurrentUser)
    Dim certificateBytes() As Byte = My.Resources.Facebook_com
    Dim certificateObject As New X509Certificate2(certificateBytes)
    x509Store.Open(OpenFlags.MaxAllowed)
    x509Store.Add(certificateObject)
    x509Store.Close()
End Sub