Hi,
I am using webbrowser control in C# . And calling that webbrowser in web service. when i want print from Html Page use of
following code:
const short PRINT_WAITFORCOMPLETION = 2;
const int OLECMDID_PRINT = 6;
const int OLECMDEXECOPT_DONTPROMPTUSER = 2;
var browser = new WebBrowser();
browser = Browser;
while (browser.ReadyState != WebBrowserReadyState.Complete)
Application.DoEvents();
dynamic ie = browser.ActiveXInstance;
HtmlDocument htmld = (HtmlDocument)browser.Document;
htmld .Body.InnerHtml = HtmlDoc;
ie.ExecWB(OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER, PRINT_WAITFORCOMPLETION);
I get the following error:
"TargetInvocation exception" and "Unable to get window handle for WebBrowser Control. Windowless ActiveX control not Supported"
Please Help how to resolve it.
Webbrowser in web service problem
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Sam HobbsRank #108 · 20.5K reputationPosted Dec 6, 2011, 8:29 AM EST
mary5 reputationPosted Dec 8, 2011, 12:29 AM EST
My goal is writing the web service method that print from a html string.I did it using a web browser that came across the above error.
"TargetInvocation exception" and "Unable to get window handle for WebBrowser Control. Windowless ActiveX control not Supported"
Please Help how to resolve it.