C# 在Windows8上安装证书X509Certificate2失败

C# 在Windows8上安装证书X509Certificate2失败,c#,certificate,windows-8.1,C#,Certificate,Windows 8.1,我正在尝试为当前用户安装一些证书到根存储。 在Windows7上,这是完美的工作,但在Windows8(特别是8.1)上,这失败了,出现未知错误。我可以在其他存储中安装证书,但不能在根存储中安装 这是我正在使用的代码 filePaths = new List<X509Certificate2>(); filePaths.Add(new X509Certificate2(eHealth_Ureg_Installer.Properties.Resources.belgiu

我正在尝试为当前用户安装一些证书到根存储。 在Windows7上,这是完美的工作,但在Windows8(特别是8.1)上,这失败了,出现未知错误。我可以在其他存储中安装证书,但不能在根存储中安装

这是我正在使用的代码

filePaths = new List<X509Certificate2>();
        filePaths.Add(new X509Certificate2(eHealth_Ureg_Installer.Properties.Resources.belgiumrca));
        filePaths.Add(new X509Certificate2(eHealth_Ureg_Installer.Properties.Resources.belgiumrca2));
        filePaths.Add(new X509Certificate2(eHealth_Ureg_Installer.Properties.Resources.belgiumrca3));
        filePaths.Add(new X509Certificate2(eHealth_Ureg_Installer.Properties.Resources.belgiumrca4));
        filePaths.Add(new X509Certificate2(eHealth_Ureg_Installer.Properties.Resources.rootct2));
        try
        {
            X509Store store = new X509Store(StoreName., StoreLocation.CurrentUser);
            store.Open(OpenFlags.ReadWrite);

            foreach (var cert in filePaths)
            {
                store.Add(cert);
            }
            store.Close();
        }
filepath=newlist();
添加(新的X509Certificate2(eHealth_Ureg_Installer.Properties.Resources.belgiumrca));
添加(新的X509Certificate2(eHealth_Ureg_Installer.Properties.Resources.belgiumrca2));
添加(新的X509Certificate2(eHealth_Ureg_Installer.Properties.Resources.belgiumrca3));
添加(新的X509Certificate2(eHealth_Ureg_Installer.Properties.Resources.belgiumrca4));
添加(新的X509Certificate2(eHealth_Ureg_Installer.Properties.Resources.rootct2));
尝试
{
X509Store=新的X509Store(StoreName.,StoreLocation.CurrentUser);
打开(OpenFlags.ReadWrite);
foreach(文件路径中的var证书)
{
存储。添加(证书);
}
store.Close();
}

你应该更加努力!