允许窗口通过Windows服务弹出

时间:2014-08-14 04:55:56

标签: c# wcf service certificate chilkat

我使用托管在Windows上的WCF服务使用电子令牌进行数字签名

电子令牌强制弹出用户名和密码,这在Windows应用程序中是可能的,但在服务中,它会抛出错误,因为它无法提示弹出窗口 " lcWriteBytes = loCryptoTest.OpaqueSignBytes(lcReadByte);"

有没有办法让Windows通过服务弹出

这是我的代码:

namespace CryptService
{

    public partial class Service1 : ServiceBase
    {

        Chilkat.Crypt2 loCryptoTest;
        Chilkat.Cert locertTest = null;

        public Service1()
        {

            InitializeComponent();
            loCryptoTest = new Chilkat.Crypt2();
            loCryptoTest.UnlockComponent("key for unlocking");
            locertTest = new Chilkat.Cert();
            bool lbsuccess = locertTest.LoadByCommonName("certificate name");

            if ((lbsuccess != true))
            {
                MessageBox.Show("Failure loading cert");
            }

            loCryptoTest.SetSigningCert(locertTest);
            byte[] lcWriteBytes = null;
            byte[] lcReadByte = loCryptoTest.ReadFile(@"D:\Test\Input.htm");
            lcWriteBytes = loCryptoTest.OpaqueSignBytes(lcReadByte);
            lcReadByte = loCryptoTest.ReadFile(@"D:\Test\Input.htm");
            lcWriteBytes = loCryptoTest.OpaqueSignBytes(lcReadByte);

            if (lcWriteBytes.Length == 0)
            {
                MessageBox.Show("Opeque Signature Error");
            }
            loCryptoTest.WriteFile(@"D:\Test\InputCrypt.htm", lcWriteBytes);
            lcReadByte = null;
            lcWriteBytes = null;
        }
    }
}

0 个答案:

没有答案