System.Windows.Forms namespace

  • Thread starter Thread starter Alex
  • Start date Start date
A

Alex

Hi,

I'm completely new to C#, so here is my question:

Why my C# program (COM dll which I can call from C++ application)
cannot see namespace

System.Windows.Forms..

When I'm typing in "using System..." after the System. the only "W"
prompt is Web, so I cannot use in my program something like
MessageBox.Show( "blah, blah, blah" );

Thanks,
Alex
 
Alex

Have you referenced System.Windows.Forms dll in VS solution explorer (if
your using VS of course).

HTH

Glenn
 
Glenn, thanks for the quick answer,

Yes, I'm writing my project using VS 2005. So currently I have in my
..cs file

using System;
using System.Runtime.InteropServices;
using System.IO;
using System.Collections.Generic;
using System.Text;

with no problem..., but ...System.Windows is not available on some
reason...
 
Right click on References in solution explorer and click Add new reference.
Then choose System.Windows.Forms.dll from the list and you are done.
 
OK, I've figured it myself, I had to go in Project->Add Reference and
add:
System.Windows.Forms.... now everything is fine. I just don't
understand why this namespace was not included in my project
automatically...
 
It depends on the project template. System.Windows.Forms.dll is referenced
only when you create a Windows Application project
 
Because it's not essential for everybody, not many people want it
included unless you have an explicit need for that..
 
Maybe the MessageBox was just an example, but just in case that's what you
intend to use:
Throwing up a MessageBox from inside an inproc COM object will rarely (never
IMHO) be a good idea.

/claes
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top