Message box not working

Book example not working

Page 1 of 1

3 Replies - 2706 Views - Last Post: 09 June 2009 - 12:11 PM Rate Topic: -----

#1 CCONNER9582002  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 35
  • Joined: 21-April 09

Message box not working

Post icon  Posted 09 June 2009 - 11:25 AM

Thanks all who helped me with my last programing issue I passed it with flying colors. I am having a issue with what the book is showing me below as a example and don't know why it isn't working could someone give me some guidince to why it won't work.


using System;
using System.Windows.Forms;
public class MessageBox2
{
	public static void Main()
	{
		MessageBox.Show("Hello all!");
	}
}


C:\Documents and Settings\cconner\My Documents\Visual Studio Projects\MESSAGEBOX\Class1.cs(2): The type or namespace name 'Windows' does not exist in the class or namespace 'System' (are you missing an assembly reference?)

Is This A Good Question/Topic? 0
  • +

Replies To: Message box not working

#2 CCONNER9582002  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 35
  • Joined: 21-April 09

Re: Message box not working

Posted 09 June 2009 - 11:37 AM

I figured it out I was using the wrong application.


View PostCCONNER9582002, on 9 Jun, 2009 - 10:25 AM, said:

Thanks all who helped me with my last programing issue I passed it with flying colors. I am having a issue with what the book is showing me below as a example and don't know why it isn't working could someone give me some guidince to why it won't work.


using System;
using System.Windows.Forms;
public class MessageBox2
{
	public static void Main()
	{
		MessageBox.Show("Hello all!");
	}
}


C:\Documents and Settings\cconner\My Documents\Visual Studio Projects\MESSAGEBOX\Class1.cs(2): The type or namespace name 'Windows' does not exist in the class or namespace 'System' (are you missing an assembly reference?)

Was This Post Helpful? 0
  • +
  • -

#3 b.ihde  Icon User is offline

  • D.I.C for life
  • member icon

Reputation: 44
  • View blog
  • Posts: 1,070
  • Joined: 29-September 08

Re: Message box not working

Posted 09 June 2009 - 11:38 AM

Hi!

Well the problem is because of your class1.cs .. Check what it is and where you use it..

regards

Ben

*Edit* Oh already solved ;)

This post has been edited by b.ihde: 09 June 2009 - 11:39 AM

Was This Post Helpful? 0
  • +
  • -

#4 lesPaul456  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 173
  • View blog
  • Posts: 729
  • Joined: 16-April 09

Re: Message box not working

Posted 09 June 2009 - 12:11 PM

I know that you have already solved the problem by changing the application type. However, I think you should know that the reason the code you were using before did not work is because you did not have a reference to the "System.Windows" namespace.

By default, console applications do not reference this namespace. If you added a reference to this namespace, the code would then work. Since winform applications need the "Sytem.Windows" namespace, there is already a reference to it. So, that is why the code worked once you change the application type.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1