locked
Thread running for printing not responding after service installation. RRS feed

  • Question

  • Hi Everyone,

    I have one windows service that i want to print HTML files. So far in debug mode service is able to print the HTML document but when installed the same service print operation would not take place.

    We want to override the Print pop-up and send print directly to a default printer so that user need not to click on print button and no selection of printer required.


    In application flow is some thing like following.

    Web application call Print -> Call the Web API method (hosted using windows service)-> Print method write HTML to temp folder and Send print to default printer.

    Following method written for printing the page.

     public void PerformPrint(string url, string title = "untitled", int copies = 1) {
                if(string.IsNullOrEmpty(url))
                    throw new ArgumentException("The url can't be null or empty");

                Navigate(url);
                
                for (var i = 0; i < copies; i++) {
                    
                    //Whithout those lines your app will crash
                    const int enabledAndSupported = 
                        (int) OLECMDF.OLECMDF_SUPPORTED + (int) OLECMDF.OLECMDF_ENABLED;

                    while ((int)_webBrowser2.QueryStatusWB(OLECMDID.OLECMDID_PRINT) != enabledAndSupported) {
                        Application.DoEvents();
                    }
                    //****************************************************************************************

                    _webBrowser2.ExecWB(
                        OLECMDID.OLECMDID_PRINT,
                        OLECMDEXECOPT.OLECMDEXECOPT_DONTPROMPTUSER,
                        null,
                        IntPtr.Zero);
                }
            }

    please help.

    Thanks & Regards,

    Naveen Upadhyay

    • Moved by Jiayi Li Monday, October 26, 2015 2:24 AM
    Friday, October 23, 2015 1:22 PM

All replies

  • Hi Naveen Upadhyay,

    This forum is about .net framework setup and servicing.

    Your issue would be related to asp.net, I suggest you could consult your issue on the asp.net forum for dedicated support: https://forums.asp.net/

    Thank you for your understanding.

    Best Regards,

    Jiayi Li


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.

    Click HERE to participate the survey.

    Monday, October 26, 2015 2:24 AM