Click to See Complete Forum and Search --> : [RESOLVED] MessageBox completely blank?
krmed
July 12th, 2005, 01:21 PM
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: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 MessageBox.Show("Hello", "Test Dialog");then the title bar will show "Test Dialog" properly.
Any clues?
(Windows XP, SP1, all critical updates).
Thanks.
MadHatter
July 12th, 2005, 01:27 PM
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.
GeeZuZz
July 12th, 2005, 02:35 PM
Just a thought - is a updated version of .net framework installed? Maybe you can try reinstalling that?
MadHatter
July 12th, 2005, 03:12 PM
i'm running 1.1 sp1 (latest & greatest for .net) here.
krmed
July 12th, 2005, 03:47 PM
Yes, unfortunately, I'm completely up to date with all SPs and the latest .NET framework.
Thanks, anyway.
darwen
July 12th, 2005, 05:22 PM
I tend to do this :
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.
MadHatter
July 12th, 2005, 06:33 PM
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.
darwen
July 12th, 2005, 06:39 PM
I've not seen this problem : but I don't pass "this" into the call to Show()
Darwen.
krmed
July 12th, 2005, 06:54 PM
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).
hoffmandirt
July 13th, 2005, 02:07 PM
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.
MadHatter
July 13th, 2005, 02:19 PM
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
hoffmandirt
July 13th, 2005, 02:28 PM
Glad to help. If you figure it out let us know, because as you said, it is very odd.
krmed
July 13th, 2005, 03:51 PM
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.
darwen
July 13th, 2005, 04:38 PM
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.
MadHatter
July 13th, 2005, 05:52 PM
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.
darwen
July 13th, 2005, 06:10 PM
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/Csharp/cs_syntax/interfaces/article.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.
MadHatter
July 13th, 2005, 06:59 PM
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.
krmed
July 14th, 2005, 05:31 AM
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.
krmed
July 14th, 2005, 05:40 AM
Just tried it on my home desktop (Norton for antivirus) and it's ok here too... Very strange.
hoffmandirt
July 14th, 2005, 09:34 AM
I have only had the problem happen with the new v8 of mcafee.
krmed
July 14th, 2005, 09:43 AM
That's an interesting note about v8 - as a matter of fact, that's what we have. I'll check into it.
Thanks.
MadHatter
July 14th, 2005, 10:11 AM
Link to McAfee's KB (https://knowledgemap.nai.com/phpclient/viewKDoc.aspx?externalID=KB_KB38881&sessionID=Anonymous|117114398&sliceID=&docID=KC.KB_KB38881&url=kb/kb_kb38881.xml&dialogID=15489717&docType=DOC_KnowledgeBase&iterationID=1&docName=Solution%20ID%20KB38881%20-%20Patch%209%20for%20McAfee%20VirusScan%20Enterprise%208.0i). I guess its a bug in gdi+. there's a link to a hotfix in the article.
krmed
July 14th, 2005, 11:24 AM
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.
krmed
July 14th, 2005, 02:24 PM
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.
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.