blue
blue

Reputation: 588

The type or namespace name 'Windows' does not exist in the namespace 'System'

I am trying to code for pop up message box for displaying message for successful record insertion in C#.net

Error :

The type or namespace name 'Windows' does not exist in the namespace 'System' (are you missing an assembly reference?)

Code :

 global::System.Windows.Forms.MessageBox.Show("Test");

Upvotes: 10

Views: 54206

Answers (5)

Andy Reed
Andy Reed

Reputation: 295

Incredibly I got this error when one of my class libraries has 'System' in its own namespace. MyCompany.Foo.Bar.Client.System as my assembly namespace must have cause a clash somewhere. Removing the 'System' from my namespace solved the problem.

Upvotes: 2

Vivek Arkalgud
Vivek Arkalgud

Reputation: 111

I am using Visual Studio 2012, Framework 4.0 for windows application. I was also getting the following message: 'the type or namespace 'windows' does not exist'

To fix this problem, I added reference to Windows.Forms.dll. After that I can display message box using the following code

System.Windows.Forms.MessageBox.Show("Completed successfully");

Upvotes: 0

Dmytro Dzyubak
Dmytro Dzyubak

Reputation: 1642

If you are using MS Visual Studio:

  1. Right click on the Project
  2. Select "Add Reference..."
  3. Navigate to the ".NET" tab
  4. Find "System.Windows.Forms" and select it
  5. Click OK.

P. S.: Additionally, I had to do the same with "System.Drawing" for everything to work correctly in my first GUI Windows program.

Upvotes: 17

meda
meda

Reputation: 45490

You are not missing any DLL , It seems like you are using the wrong type of project.

Upvotes: 7

Darin Dimitrov
Darin Dimitrov

Reputation: 1038810

global::System.Windows.Forms.MessageBox.Show("Test"); in an ASP.NET MVC application? And where did you expect this message box to pop out?

In an ASP.NET MVC application you could use client side javascript to show message boxes.

For example inside your view you could put the following:

<script type="text/javascript">
    alert('Test');
</script>

And when you navigate to the corresponding controller action the user will be greeted with the message box.

Upvotes: 10

Related Questions