views:

187

answers:

3

Hi there, I've got a service that's acting up. It won't recognize the following namespace declaration:

using System.Windows.Forms;

What I most need from the Windows.Forms namespace is a WebBrowser control. Any ideas on how to get this working? Thank you.

A: 

you need to add reference to it's assembly

right click your project node in solutions explorer and

choose AddReference --> .Net -->System.Windows.Forms

Asad Butt
+2  A: 

Add a reference to System.Windows.Forms in the project.

Just make sure that you don't call MessageBox from your service. It is not a smart thing to do. (Yes, I have blocked services that way)

Arve
Fixed it right up, thank you :-)
Sam Youtsey
Correct answer to the question, but this is totally the wrong thing to do. A Windows service should never interact with the desktop. If the service really needs a UI element, create it as a separate binary that runs in the context of the logged on user, and communicates with the service process.
Bryan
A: 

I'm not sure how you expect to use a WebBrowser control in a Windows service, a type of application that inherently does not have a user interface. What you probably need is a reference to the System.Windows.Forms library. If you right click on your project and go to Add Reference..., there will be a whole list of reference. Scroll down and select System.Windows.Forms and clikc OK and you should be good to go.

Jeff Hornby