使用interop.excel向excel文件添加不可见数字签名时,禁止签名对话框 [英] suppress sign dialogu when adding invisible digital signature to excel file using interop.excel

查看:111
本文介绍了使用interop.excel向excel文件添加不可见数字签名时,禁止签名对话框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好。我正在使用asp.net c#中的以下代码向excel文件添加数字签名。一切都做得很好。我的问题是我打电话时出现的对话框: 签名objSignature = signatureSet.Add();

然后程序停止并等待用户交互。我需要压制此对话框并让代码运行结束。任何人都可以帮忙吗?这是代码:


 


         &NBSP&NBSP ;   对象遗漏= System.Reflection.Missing.Value;

                Microsoft.Office.Interop.Excel.Application exceldapp =新Microsoft.Office.Interop.Excel.Application();

                 Microsoft.Office.Interop.Excel.Workbook excelwb = exceldapp.Workbooks.Open(TempFilePath,      Type.Missing,Type.Missing,Type.Missing,Type.Missing,

                       &NBSP ;   Type.Missing,Type.Missing,Type.Missing,Type.Missing,

          &NBSP ;                Type.Missing,Type.Missing,Type.Missing,Type.Missing,

                      &NBSP ;    Type.Missing,Type.Missing);
$


                 SignatureSet signatureSet = excelwb.Signatures;

               签名objSignature = signatureSet.Add();

                if(objSignature == null)

                {

                   返回false;

                }
               否则b $ b                {

                    signatureSet.Commit();

                    对象的SaveChanges = TRUE;

                  &NBSP ; excelwb.Close(调用SaveChanges,缺失,缺失的);

               &NBSP ;    downloadFile(TempFilePath);

                  &NBSP ;返回true;

                }




解决方案

Hello Parviz,


>在asp.net c#中使用以下代码。


Microsoft目前不建议也不支持从任何无人参与的非交互式客户端应用程序或组件(包括ASP,ASP)自动化Microsoft Office应用程序.NET,DCOM和NT服务),因为在此环境中运行Office时,Office
可能会出现不稳定的行为和/或死锁。




如果要构建在服务器端上下文中运行的解决方案,则应尝试使用已为安全无人值守执行的组件。或者,您应该尝试找到允许至少部分代码在客户端运行的替代方法。
如果从服务器端解决方案使用Office应用程序,则应用程序将缺少许多必要的功能才能成功运行。此外,您将承担整体解决方案稳定性的风险。在
中了解更多相关信息
服务器端Office自动化的注意事项
文章。



作为一种解决方法,您可以考虑使用专为服务器端执行而设计的第三方组件,或仅使用
如果您处理打开,请
Open XML SDK
文件格式 文件。  


Hi. i am adding a digital signature to an excel file using the below code in asp.net c#. All is done well. My problem is the dialog which appears when i call :  Signature objSignature = signatureSet.Add();
then the program stops and waits for user interaction. I need to suppress this dialog and let the code to run to end.Can anybody help please ? this is the code :

         

       object missing = System.Reflection.Missing.Value;
                Microsoft.Office.Interop.Excel.Application exceldapp = new Microsoft.Office.Interop.Excel.Application();
                Microsoft.Office.Interop.Excel.Workbook excelwb = exceldapp.Workbooks.Open(TempFilePath,      Type.Missing,Type.Missing, Type.Missing, Type.Missing,
                           Type.Missing, Type.Missing, Type.Missing, Type.Missing,
                           Type.Missing, Type.Missing, Type.Missing, Type.Missing,
                           Type.Missing, Type.Missing);

                SignatureSet signatureSet = excelwb.Signatures;
                Signature objSignature = signatureSet.Add();
                if (objSignature == null)
                {
                    return false;
                }
                else
                {
                    signatureSet.Commit();
                    object saveChanges = true;
                    excelwb.Close(saveChanges, missing, missing);
                    downloadFile(TempFilePath);
                    return true;
                }


解决方案

Hello Parviz,

> using the below code in asp.net c#.

Microsoft does not currently recommend, and does not support, Automation of Microsoft Office applications from any unattended, non-interactive client application or component (including ASP, ASP.NET, DCOM, and NT Services), because Office may exhibit unstable behavior and/or deadlock when Office is run in this environment.

If you are building a solution that runs in a server-side context, you should try to use components that have been made safe for unattended execution. Or, you should try to find alternatives that allow at least part of the code to run client-side. If you use an Office application from a server-side solution, the application will lack many of the necessary capabilities to run successfully. Additionally, you will be taking risks with the stability of your overall solution. Read more about that in the Considerations for server-side Automation of Office article.

As a workaround you may consider using a third-party components designed for the server-side execution or just Open XML SDK if you deal with open file format documents.  


这篇关于使用interop.excel向excel文件添加不可见数字签名时,禁止签名对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆