1

I am developing an application for Windows CE using Visual Studio 2008.

Code:

    private void cmdLogOn_Click(object sender, EventArgs e)
      {
        if (loginStatus == false)
        {
            DialogResult dialogresult = MessageBox.Show("Are you sure?", "text", MessageBoxButtons.YesNo);
            if (dialogresult == DialogResult.Yes)
            {
                //Do Stuff;
            }
        }
        else
        {
            //Do stuff
        }
    }

I am getting the error : "No overload for method 'Show' takes '3' arguments". Any idea why?

EDIT: Here is a step by step using a new application to demonstrate the issue:

  1. As you can see, I am using VS2008

enter image description here

2.Visual C# > Smart Device Project

enter image description here

  1. Target platform: Windows CE - .NET Compact Framework Version 3.5

enter image description here

  1. I create a button = button1 & a label = label1

enter image description here

  1. Here is the code I entered, but the error persists

enter image description here

davidvnog
  • 654
  • 2
  • 11
  • 33

4 Answers4

1

One plausible explanation is that you are targetting .net 1 which, for the compact framework, only has a single MessageBox.Show method that accepts a single parameter of type string.

Support in the compact framework for the overload that you seek to use was added in .net 2.0, at least as far as I can tell from the documentation.

You state in comments that you are using .net 3.5. In which case the only sane conclusion to draw would be that MessageBox must be something other than System.Windows.Forms.MessageBox, since that class, in .net 3.5, on the compact framework, has the overload you seek to call.

Finally, @CathalMF asserts that the overload really is not present in the compact framework. Maybe the documentation is just wrong!

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490
1

You can try something like this:

MessageBox.Show("my text", "title", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation, 
    MessageBoxDefaultButton.Button1);

Source

Lews Therin
  • 3,707
  • 2
  • 27
  • 53
Burak Karakuş
  • 1,368
  • 5
  • 20
  • 43
1

The simple answer is in the .NET Compact framework there is no overload which takes 3 arguments, as the error says.

You can use this:

DialogResult dialogresult = MessageBox.Show("Are you sure?", "text",
    MessageBoxButtons.YesNo, MessageBoxIcon.None, MessageBoxDefaultButton.Button1);
Lews Therin
  • 3,707
  • 2
  • 27
  • 53
CathalMF
  • 9,705
  • 6
  • 70
  • 106
  • In any other non compact framework application I am able to do what I did, it worked your way! Thanks! – davidvnog Jul 14 '14 at 11:38
  • 1
    Ya there are loads of overloads which work in the Full framework which don't work in the compact framework. – CathalMF Jul 14 '14 at 11:45
-3

you have to use the System.Windows.Forms

System.Windows.Forms.DialogResult dialogresult = System.Windows.Forms.MessageBox.Show("Are you sure?", "text", System.Windows.Forms.MessageBoxButtons.YesNo);
Dhaval Patel
  • 7,471
  • 6
  • 37
  • 70