none
suppress sign dialogu when adding invisible digital signature to excel file using interop.excel RRS feed

  • Question

  • 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;
                    }


    Thursday, May 31, 2018 9:52 AM

All replies

  • 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.  


    profile for Eugene Astafiev at Stack Overflow, Q&A for professional and enthusiast programmers

    Thursday, May 31, 2018 11:46 AM