[RESOLVED] MessageBox completely blank?
Hi,
I'm just starting to look at C#, and in trying some samples, I have a strange problem - perhaps it's just this machine (I'll try it at home later).
I create a simple Windows Application and on the form I place one button.
In the event handler for the button, I simply put:
Code:
MessageBox.Show("Hello");
The message box pops up, but it is completely blank! Title bar is the correct color, background is the correct color, button is present (but no OK or any other text on the button), no text in the message box and no text in the title bar.
If I change it to
Code:
MessageBox.Show("Hello", "Test Dialog");
then the title bar will show "Test Dialog" properly.
Any clues?
(Windows XP, SP1, all critical updates).
Thanks.
Re: MessageBox completely blank?
I have that same problem on my laptop here at work. I figured it was a video driver issue. it actually happens on other window controls. I've found that if I open up a modal child and move it over the window that has the same behavior that the text shows back up.
I have the same setup & would be interested in finding out as well.
Re: MessageBox completely blank?
Just a thought - is a updated version of .net framework installed? Maybe you can try reinstalling that?
Re: MessageBox completely blank?
i'm running 1.1 sp1 (latest & greatest for .net) here.
Re: MessageBox completely blank?
Yes, unfortunately, I'm completely up to date with all SPs and the latest .NET framework.
Thanks, anyway.
Re: MessageBox completely blank?
I tend to do this :
Code:
MessageBox.Show("Hello", System.Windows.Forms.Application.ProductName);
Which means if the assembly product name is set to an appropriate value in the application (it's in the "AssemblyInfo.cs" file) then the message box always picks up the correct title.
Darwen.
Re: MessageBox completely blank?
this is what it looks like:
http://www.sanity-free.org/images/unpainted.jpg
notice that the main form is painted correctly but the messagebox is not. the title shows up but the content and button name do not.
Re: MessageBox completely blank?
I've not seen this problem : but I don't pass "this" into the call to Show()
Darwen.
Re: MessageBox completely blank?
Well, I've tried it on my laptop at home, and it works properly there. It must be somthing with the office machine (or the way IT has the restrictions on something set).
Thanks for the feedback (and the tip on the application name).
Re: MessageBox completely blank?
Do you happen to be running Mcafee virus scan or any other Mcafee products? I had the same problem on a pc at school which was recently updated with the newest mcafee virus scanner. The weirdest thing was the message box would come up blank like that if mcafee was running and if I killed mcafee, the message box would work fine. I have no idea how mcafee could effect the message box, but it seemed to here.
Re: MessageBox completely blank?
that is absolutely the case. very odd indeed. disabling the buffer overflow protection gets it back online.
guess somethings going wrong there. wonder if its win32 or .net?
looks like I have some sherlock holmes work to do :D
Re: MessageBox completely blank?
Glad to help. If you figure it out let us know, because as you said, it is very odd.
Re: MessageBox completely blank?
That's interesting, because on my office machine, we have McAfee (and cannot disable it), whereas on my home machines I use Norton and don't have the problem.
Thanks for the info.
Re: MessageBox completely blank?
I've got McAfee at home and at work (active scan turned on) and it's never failed for me yet.
Are you Windows Update-ing regularly ?
Darwen.
Re: MessageBox completely blank?
its not the "virus scanner" I work off of 2 - 3 machines here at work. they all have macaffee enterprise, but only my laptop has this buffer overflow protection service on it (its v8 the others are v7 and dont have that feature to them).
if I turn off that piece it shows up. from what I've read it most likely is seeing the system writing to memory and thinks its attempting a buffer overflow and disallows it. that or there is some slight problem with the way .NET implement the system's fonts. I havent had time to look at it.
my system is always up to date. the other machines are dev test machines and they are always tested daily to make sure they have the latest & greatests.
Re: MessageBox completely blank?
Actually - you raised a good point here MH.
Are you calling the Dispose() on all your GDI+ objects ?
If you're not, then you're asking for trouble. It's entirely possible (and unpredicatable) what behaviour you see when you have a huge number of GDI resources allocated to the application.
You MUST release GDI resources (e.g. Font, Brush, Pen etc classes) whenever you're finished with them.
You do this by calling the Dispose() method on them, or by the "using" keyword which I've written an article about :
http://www.codeguru.com/Csharp/Cshar...cle.php/c8679/
It may just be that you're running out of resources.
To check all you really need to do is to run task manager, processes tab and after selecting the "view/select columns" menu item make sure "GDI objects" is selected.
You can then keep track of all GDI objects in the system - if the number is growing and never decreasing then you've got a problem.
I don't know, but I'd be willing to bet the maximum GDI resource allocations will differ between machines, and certainly OSes.
I'm always very tidy with my GDI resources : I always release them after using them unless I'm explicitly caching them for speed reasons. Maybe that's why I haven't seen your problems.
Another thing to check is running under MTAThread rather STAThread. I've had problems with MTAThread (mainly with the common dialogs) but there may be other problems which I've not experienced.
Darwen.
Re: MessageBox completely blank?
I've run the message box from both P/Invoke and through the one provided in System.Windows.Forms. I want to test it with straight win32 code and see if it has the same result.
I have a feeling its .net's implementation somewhere. the win32 tests should show that. It seems to be associated with the app as it loads not adhoc as its running (as enable/disabling the b/o has no effect on the app after its started).
I've had system font problems before and know that everythings not on the up and up there, so that will be my first place I look.
Re: MessageBox completely blank?
Thanks darwen.
I run Windows Update regulary and in fact just updated on Tuesday (there were new updates). I keep it turned on to tell me when there are new updates available.
I hope I can find a solution in this thread, as the application I'm beginning with (from a MS book) is extremely simple and doesn't include using bunches of resources or such.
I hope the simple needs I have at this point don't get lost with MH's problem, but hopefully both can be resolved.
I was thinking of having the IT folks turn off my McAfee for 10 minutes this morning so I can test.
Re: MessageBox completely blank?
Just tried it on my home desktop (Norton for antivirus) and it's ok here too... Very strange.
Re: MessageBox completely blank?
I have only had the problem happen with the new v8 of mcafee.
Re: MessageBox completely blank?
That's an interesting note about v8 - as a matter of fact, that's what we have. I'll check into it.
Thanks.
Re: MessageBox completely blank?
Link to McAfee's KB. I guess its a bug in gdi+. there's a link to a hotfix in the article.
Re: MessageBox completely blank?
Thanks for the link... I disabled the McAfee, but it didn't make any difference.
I sent the link to our IT department to see if they can help resolve the issue.
Re: MessageBox completely blank?
Good News!!! (no, it's not GEICO)
I adjusted McAfee 8.0i through the console to disbale buffer overflow checking, and all the problems have disappeared. (Didn't have to apply any patches).
I notified IT, so we'll see what they have come up with.
Thanks again to all who helped.