string certPath = string.Format(@"{0}\Aaa.cer", Environment.GetFolderPath(Environment.SpecialFolder.System));
X509Certificate2 certificate = new X509Certificate2(certPath);
X509Store trustedPublisherStore = new X509Store(StoreName.TrustedPublisher, StoreLocation.LocalMachine);
X509Store trustedAuthorityRootStore = new X509Store(StoreName.AuthRoot, StoreLocation.LocalMachine);
try
{
X509Store trustedPublisherStore = new X509Store(StoreName.TrustedPublisher, StoreLocation.LocalMachine);
X509Store trustedAuthorityRootStore = new X509Store(StoreName.AuthRoot, StoreLocation.LocalMachine);
try
{
trustedPublisherStore.Open(OpenFlags.ReadWrite);
trustedPublisherStore.Add(certificate);
trustedAuthorityRootStore.Open(OpenFlags.ReadWrite);
trustedAuthorityRootStore.Add(certificate);
}
catch (Exception ex)
{
}
catch (Exception ex)
{
MessageBox.Show(ex.Message + "\n\n" + ex.StackTrace);
}
}
finally
{
{
trustedPublisherStore.Close();
trustedAuthorityRootStore.Close();
}
}
For more information about Signing & Deploying CAB Based ClickOnce Code.
Please refer the following link to know more about “WPF - XBAP as Full Trust Application”