Error: "Show is not a member of MessageBox" on VB 2010 school computers

Solitaire

Well-known member
Joined
Jun 28, 2004
Messages
465
Location
New York
Programming Experience
10+
Today I introduced the MessageBox.Show method in my course. We are using the VB 2010 Express version. The demo sample I used worked perfectly. I had converted it from VB 2008 at home, and it was still using .NET 3.5.

But when I started a new exercise with my students, the MessageBox.Show() didn't work. (This was a Windows Forms application, NOT a Console app.) After typing the dot, the Show method did not appear in the intellisense box, and an error came up saying that Show was not a member of MessageBox. More than half my students had the same error. We were forced to use the MsgBox function instead.

I vaguely recall having had the same issue in school when VB 2008 first came out. Is the current problem some kind of bug in .NET 4.0 that wasn't corrected and needed a patch?

I don't have access to the network, nor are teachers given admin rights to the computers, so I can't make any upgrades on my own.

My installation at home works just fine, probably because I had all upgrades installed.

Please advise before I attempt to notify the IT staff at the school.
 
My guess would be that you have a name clash. Is your project named MessageBox by any chance? If so then the compiler will interpret any use of MessageBox as the root namespace of your project rather then the MessageBox class. In that case, your options are:

1. Qualify the MessageBox class in code, i.e. use Windows.Forms.MessageBox.
2. Change the root namespace of the project to something other than MessageBox, which you would do in the project properties.
3. Create a new project and use a different name, which will then be used as the roo namespace as well.
 
You are right on the button! That is exactly what happened! The project was named "MessageBox." I just tried it at home and sure enough, I got the same error.

Thank you so much!! Problem solved! I will notify my students. I just have to try it at school (my class meets on Wednesday) to verify that MessageBox.Show() works with a different project name.
 
If you hang around forums like this one long enough then you're bound to see everything at least once. This is definitely not the first time I've seen this issue, i.e. a name clash created by the project name.
 
Back
Top