Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8928661
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T08:29:43+00:00 2026-06-15T08:29:43+00:00

Am trying to print a file from server side via a WCF service deployed

  • 0

Am trying to print a file from server side via a WCF service deployed on IIS machine.
The following code gets worked on Win 2oo3 machine perfectly. But the same code is throwing a COM exception. Any idea about this. I guess its related to some permissions.
Here is the code

public void Print(string htmlFilename, string printer, short copies)
        {
            string currDefault = string.Empty;
            try
            {
                currDefault = GetDefaultPrinter();
                myPrinters.SetDefaultPrinter(printer);
                for (int i = 0; i < copies; i++)
                {
                    documentLoaded = false;
                    documentPrinted = false;

InternetExplorer  ie = new InternetExplorer  ();
                    ie.DocumentComplete += new SHDocVw.DWebBrowserEvents2_DocumentCompleteEventHandler(ie_DocumentComplete);
                    ie.PrintTemplateTeardown += new SHDocVw.DWebBrowserEvents2_PrintTemplateTeardownEventHandler(ie_PrintTemplateTeardown);
                    object missing = Missing.Value;

                    ie.Navigate(htmlFilename, ref missing, ref missing, ref missing, ref missing);
                    while (!documentLoaded && ie.QueryStatusWB(SHDocVw.OLECMDID.OLECMDID_PRINT) != SHDocVw.OLECMDF.OLECMDF_ENABLED)
                        Thread.Sleep(100);


                    ie.ExecWB(SHDocVw.OLECMDID.OLECMDID_PRINTPREVIEW, SHDocVw.OLECMDEXECOPT.OLECMDEXECOPT_DODEFAULT, ref missing, ref missing);

                    ie.ExecWB(SHDocVw.OLECMDID.OLECMDID_PRINT, SHDocVw.OLECMDEXECOPT.OLECMDEXECOPT_DONTPROMPTUSER, ref missing, ref missing);
                    while (!documentPrinted)
                        Thread.Sleep(100);

                    ie.DocumentComplete -= ie_DocumentComplete;
                    ie.PrintTemplateTeardown -= ie_PrintTemplateTeardown;
                    ie.Quit();
                }
            }
            catch { throw; }
            finally
            {
                myPrinters.SetDefaultPrinter(currDefault);
            }
        }

And the Com Exception is as below exactly while creating an object for internetexplorer.

[ERRORLOG] Retrieving the COM class factory for component with CLSID
{0002DF01-0000-0000-C000-000000000046} failed due to the following
error: 80080005 Server execution failed (Exception from HRESULT:
0x80080005 (CO_E_SERVER_EXEC_FAILURE)). : at
System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean
publicOnly, Boolean noCheck, Boolean& canBeCached,
RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck) at
System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean
skipCheckThis, Boolean fillCache) at
System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly,
Boolean skipVisibilityChecks, Boolean skipCheckThis, Boolean
fillCache) at System.Activator.CreateInstance(Type type, Boolean
nonPublic) at System.Activator.CreateInstance(Type type)
[/ERRORLOG]

Moreover if i try to create an object as InternetExplorerMedium. then its working in 2008 but not in Win server 2003. I was very much clue less… Any help regarding will help a lot.

Regards,
Pavan N

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T08:29:44+00:00Added an answer on June 15, 2026 at 8:29 am

    Finally i changed my own logic itself. I observed lot of difference w.r.t IE. especially IE9. all the DCOM seetings will be different. so with the name InternetExplorer ie = new InternetExplorer (); you cant create any object. its not either related to permission or OS. its related to IE version. Above code works only upto IE8.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im trying to read in image file from a server , with the code
I am having some trouble trying to print from a file. Any ideas? Thanks
I am trying to print a .txt file that my application saves via FileWriter.
I'm trying to print a query result to file from MySQL ( SELECT blah
I've been trying to send a packet from a client to a server via
I'm trying to save a dynamic pdf file generated from a web server using
I am trying to transfer a file from one server to another. I am
I am trying to download a .zip file from a FTP server and I
I´m trying to upload a file which is fetched from a server. But when
I'm trying to open a file and read from the last point read. My

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.