|
Hello,
Since the last few days I get "GDI+ is not properly initialized (internal GDI+ error)" errors regularly in the application I am developing. They usually appear after I have selected a file in a OpenFileDialog, but the errors are not consistent. If I try to open the same file multiple times, I do not always get the error, sometimes the application just works as it should.
So that makes me think that it is not necessarily the code I wrote that is causing this problem, but something else. Unfortunately the error message is not really clear in telling me what and where it goes wrong. So does anybody have an idea what is the most common cause of this kind of error or how I could debug (and solve) it further?
I am using C# and VS2005 to develop my application.
Thanks,
| | Arno Gerretsen Thursday, December 27, 2007 12:39 PM | I too am seeing these same errors which appear to be caused by the OpenFileDialog.
The errors manifest themselves when pressing OK, and sometimes, just single-clicking on a selected file. Any one with some ideas?
Thanks.
| | Craig Bye Friday, January 11, 2008 11:14 PM | Here is a stack trace of the crash:
***************Exception*************** Unhandled Thread Exception Caught! System.Runtime.InteropServices.ExternalException: GDI+ is not properly initialized (internal GDI+ error). at System.Drawing.Graphics.FromHdcInternal(IntPtr hdc) at System.Windows.Forms.PaintEventArgs.get_Graphics() at System.Windows.Forms.Control.PaintBackColor(PaintEventArgs e, Rectangle rectangle, Color backColor) at System.Windows.Forms.Control.PaintBackground(PaintEventArgs e, Rectangle rectangle, Color backColor, Point scrollOffset) at System.Windows.Forms.Control.PaintBackground(PaintEventArgs e, Rectangle rectangle) at System.Windows.Forms.Control.OnPaintBackground(PaintEventArgs pevent) at System.Windows.Forms.ScrollableControl.OnPaintBackground(PaintEventArgs e) at System.Windows.Forms.TableLayoutPanel.OnPaintBackground(PaintEventArgs e) at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer, Boolean disposeEventArgs) at System.Windows.Forms.Control.WmEraseBkgnd(Message& m) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.ScrollableControl.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
The thread 0x70 has exited with code 0 (0x0). The thread 0x7f8 has exited with code 0 (0x0). The thread '<No Name>' (0xff4) has exited with code 0 (0x0). The thread 'Win32 Thread' (0x70) has exited with code 0 (0x0). The thread 'Win32 Thread' (0xff4) has exited with code 0 (0x0). The thread 'Win32 Thread' (0x7f8) has exited with code 0 (0x0). First-chance exception at 0x7c80976f in Optimizer.exe: 0xC0000005: Access violation writing location 0x03847c24. First-chance exception at 0x7c812a5b in Optimizer.exe: 0xC0000005: Access violation writing location 0x03847c24. A first chance exception of type 'System.AccessViolationException' occurred in System.Drawing.dll An exception of type 'System.AccessViolationException' occurred in System.Drawing.dll but was not handled in user code
Additional information: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
| | Craig Bye Monday, January 14, 2008 7:51 PM | There appears to be several people seeing the same issue and it has been acknowledged by Microsoft in this posting: https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=108996&wa=wsignin1.0However, I don't know how to get my hands on the solution: new system.drawing.dll and gdiplus.dll Anyone with any ideas? | | Craig Bye Wednesday, January 16, 2008 11:52 PM | I have exactly the same simptoms when using OpenFileDialog. I am using VS2005 Team edition. My collegue does not have this problem running the same code. Reinstalling VS2005 or even Windows didn't help. The link in the previous post aknowledges a similar problem but doesn't really give a solution. Is there a hotfix available or a workaround?
| | Oban Longmorn Tuesday, February 05, 2008 12:07 PM | I got the same problem too recently. Often happens with FileDialog but not always.
The machine is XP Pro x64 with all updates. The process is a 32-bit.
-
An exception of type 'System.Runtime.InteropServices.ExternalException' occurred in System.Drawing.dll but was not handled in user code Additional information: GDI+ is not properly initialized (internal GDI+ error).
Callstack:
System.Drawing.dll!System.Drawing.Graphics.FromHdcInternal(System.IntPtr hdc) + 0x7e bytes System.Windows.Forms.dll!System.Windows.Forms.PaintEventArgs.Graphics.get() + 0x3f bytes System.Windows.Forms.dll!System.Windows.Forms.Control.PaintBackColor(System.Windows.Forms.PaintEventArgs e = {ClipRectangle = {X=0,Y=0,Width=986,Height=579}}, System.Drawing.Rectangle rectangle, System.Drawing.Color backColor) + 0x5a bytes System.Windows.Forms.dll!System.Windows.Forms.Control.PaintBackground(System.Windows.Forms.PaintEventArgs e, System.Drawing.Rectangle rectangle, System.Drawing.Color backColor, System.Drawing.Point scrollOffset) + 0x97 bytes System.Windows.Forms.dll!System.Windows.Forms.Control.PaintBackground(System.Windows.Forms.PaintEventArgs e, System.Drawing.Rectangle rectangle) + 0x63 bytes System.Windows.Forms.dll!System.Windows.Forms.Control.OnPaintBackground(System.Windows.Forms.PaintEventArgs pevent) + 0xd1 bytes System.Windows.Forms.dll!System.Windows.Forms.ScrollableControl.OnPaintBackground(System.Windows.Forms.PaintEventArgs e) + 0x38 bytes WindowsFormsIntegration.dll!System.Windows.Forms.Integration.WinFormsAdapter.OnPaintBackground(System.Windows.Forms.PaintEventArgs e) + 0x1d bytes System.Windows.Forms.dll!System.Windows.Forms.Control.PaintWithErrorHandling(System.Windows.Forms.PaintEventArgs e = {ClipRectangle = {X=0,Y=0,Width=986,Height=579}}, short layer, bool disposeEventArgs = true) + 0x74 bytes System.Windows.Forms.dll!System.Windows.Forms.Control.WmEraseBkgnd(ref System.Windows.Forms.Message m = {msg=0x14 (WM_ERASEBKGND) hwnd=0x141054 wparam=0x1501216b lparam=0x0 result=0x0}) + 0xe1 bytes System.Windows.Forms.dll!System.Windows.Forms.Control.WndProc(ref System.Windows.Forms.Message m) + 0x28b bytes System.Windows.Forms.dll!System.Windows.Forms.ScrollableControl.WndProc(ref System.Windows.Forms.Message m) + 0x45 bytes System.Windows.Forms.dll!System.Windows.Forms.ContainerControl.WndProc(ref System.Windows.Forms.Message m) + 0x11 bytes System.Windows.Forms.dll!System.Windows.Forms.Control.ControlNativeWindow.OnMessage(ref System.Windows.Forms.Message m) + 0xd bytes System.Windows.Forms.dll!System.Windows.Forms.Control.ControlNativeWindow.WndProc(ref System.Windows.Forms.Message m) + 0x36 bytes System.Windows.Forms.dll!System.Windows.Forms.NativeWindow.DebuggableCallback(System.IntPtr hWnd, int msg = 0x00000014, System.IntPtr wparam, System.IntPtr lparam) + 0x57 bytes [Native to Managed Transition] user32.dll!7d9472d8() [Frames below may be incorrect and/or missing, no symbols loaded for user32.dll] user32.dll!7d947568() user32.dll!7d947506() user32.dll!7d94aee9() [Managed to Native Transition] WindowsBase.dll!MS.Win32.HwndSubclass.SubclassWndProc(System.IntPtr hwnd, int msg, System.IntPtr wParam, System.IntPtr lParam) + 0x23c bytes [Native to Managed Transition] user32.dll!7d9472d8() user32.dll!7d947568() user32.dll!7d947506() user32.dll!7d947d93() user32.dll!7d98a3e9() user32.dll!7d947e46() [Managed to Native Transition] PresentationFramework.dll!System.Windows.Interop.HwndHost.OnVisibleChanged(object sender, System.Windows.DependencyPropertyChangedEventArgs e) + 0x50 bytes PresentationCore.dll!System.Windows.UIElement.RaiseDependencyPropertyChanged(System.Windows.EventPrivateKey key, System.Windows.DependencyPropertyChangedEventArgs args) + 0x75 bytes PresentationCore.dll!System.Windows.UIElement.OnIsVisibleChanged(System.Windows.DependencyObject d, System.Windows.DependencyPropertyChangedEventArgs e) + 0x58 bytes WindowsBase.dll!System.Windows.DependencyObject.OnPropertyChanged(System.Windows.DependencyPropertyChangedEventArgs e) + 0x51 bytes PresentationFramework.dll!System.Windows.FrameworkElement.OnPropertyChanged(System.Windows.DependencyPropertyChangedEventArgs e) + 0x40 bytes WindowsFormsIntegration.dll!System.Windows.Forms.Integration.WindowsFormsHost.OnPropertyChanged(System.Windows.DependencyPropertyChangedEventArgs e) + 0x26 bytes WindowsBase.dll!System.Windows.DependencyObject.NotifyPropertyChange(System.Windows.DependencyPropertyChangedEventArgs args) + 0x2b bytes PresentationCore.dll!System.Windows.UIElement.UpdateIsVisibleCache() + 0x151 bytes PresentationCore.dll!System.Windows.UIElement.OnVisibilityChanged(System.Windows.DependencyObject d, System.Windows.DependencyPropertyChangedEventArgs e) + 0x66 bytes WindowsBase.dll!System.Windows.DependencyObject.OnPropertyChanged(System.Windows.DependencyPropertyChangedEventArgs e) + 0x51 bytes PresentationFramework.dll!System.Windows.FrameworkElement.OnPropertyChanged(System.Windows.DependencyPropertyChangedEventArgs e) + 0x40 bytes WindowsFormsIntegration.dll!System.Windows.Forms.Integration.WindowsFormsHost.OnPropertyChanged(System.Windows.DependencyPropertyChangedEventArgs e) + 0x26 bytes WindowsBase.dll!System.Windows.DependencyObject.NotifyPropertyChange(System.Windows.DependencyPropertyChangedEventArgs args) + 0x2b bytes WindowsBase.dll!System.Windows.DependencyObject.UpdateEffectiveValue(System.Windows.EntryIndex entryIndex, System.Windows.DependencyProperty dp = {Visibility}, System.Windows.PropertyMetadata metadata, System.Windows.EffectiveValueEntry oldEntry, ref System.Windows.EffectiveValueEntry newEntry = {System.Windows.EffectiveValueEntry}, bool coerceWithDeferredReference, System.Windows.OperationType operationType) + 0x53b bytes WindowsBase.dll!System.Windows.DependencyObject.SetValueCommon(System.Windows.DependencyProperty dp, object value, System.Windows.PropertyMetadata metadata, bool coerceWithDeferredReference, System.Windows.OperationType operationType, bool isInternal) + 0x357 bytes WindowsBase.dll!System.Windows.DependencyObject.SetValue(System.Windows.DependencyProperty dp, object value) + 0x33 bytes PresentationCore.dll!System.Windows.UIElement.Visibility.set(System.Windows.Visibility value) + 0x2f bytes ...
| | Peter Westerström Thursday, February 14, 2008 4:07 AM | If found what was causing this bug in my case: Turtoise CVS 1.10.1 ( - 1.10.4).
Once Turtoiseis uninstalled, the OpenFileDialog works as normal. Older versions of Turtoise, 1.8.x work fine. | | Oban Longmorn Friday, February 15, 2008 9:06 AM | Interesting. I too have TortoiseCVS 1.10.1 installed. The problem showed up when I switched to a faster computer and never made the connection that I upgraded Tortoise at that time. I will confirm Tortoise versions with the rest of our team since some people have not seen this issue.
| | Craig Bye Friday, February 15, 2008 3:27 PM | I've checked it with TortoiseCVS 1.10.4, which has been reported to show the same behavior. However, I haven't been able to reproduce the issue(s).
Searching on the web it turned up, that someone was using TortoiseCVS 1.10.1 for several months (the person claimed 6 months, which is hardly possible since it was released 2007-12-02). However, that person mentioned that the problems only started after some updates through Windows update. That's what I am checking at the moment. Given the release dates, we can rule out certain updates. Also, I do not think that TortoiseCVS is the culprit per-se. But I think it is part of the problem by implicitly changing the DLL search path during its installation. This means that particular DLLs take precedence over other more centrally located DLLs now. Will try to find the reason for this and report back.
| | Ratatöskr Thursday, March 13, 2008 12:11 AM | I've just stumbled across this post via Google - I was running 1.10.1, so took the advice and reinstalled to 1.10.4; this appears to have fixed the issue. Perhaps the reinstall forces the DLL chain to be reevaluated post-Microsoft update? No idea, but just a thought. Anyway... 1.10.4 *appears* to fix it. Good luck folks!  ) Ian | | Ian Grimstead Thursday, March 13, 2008 2:33 PM | Aaaaaargh. Check that. Looks like I accidently used my app in an alternate manner - the bug is still there, tied to the OpenFile/SaveFile dialogue (VC++ 2005 and 2008). Strange. It appears to trigger if I also use a separate tab pane (nothing technical in it, just a radio button set for configuration) before using the OpenFile dialogue (or SaveFile for that matter).
Might be due to timings of when something is launched from within the debugger. Wierd.
Note that the above error does not occur on another machine, running the same code, but *without* TortoiseCVS (it does, however, have TortoiseSVN).
Hmmn.
Ian
| | Ian Grimstead Thursday, March 13, 2008 4:07 PM | Myself and another guy in our office have both been running Tortoise CVS 1.10.3 and getting the same error Going back to 1.8.x has fixed this problem for us too.
| | Guy Newbery Monday, March 17, 2008 12:09 PM | I was having the same problem. I un-installed Tortoise CVS 1.10.1 then rebootedand the issue went away. I installed Tortoise CVS 1.10.5, rebootedand the issue came back. I un-installed Tortoise CVS 1.10.5 and the issue went away (no-reboot).
Guess I will go back to 1.8.x if I need Tortoise CVS again. | | Alva P Monday, March 31, 2008 5:32 PM | I also experienced this problem, but the circumstances have allowed me to define the issue a tad better. I am developing a large fundamental graphics project on VC++ 2005 and recently upgraded my workstation. I developed the project for 14 months on the old workstation. The program I am developing combines a thin layer of managed C++ code over a large amount of unmanaged C++ static libraries, using the IJW switch. The software worked very well on the DualCore, without memory leaks or interop issues. It had an Asus Windows Vista Edition motherboard, with a dual-core Intel CPU, 2 gigs RAM and an ATI 1950x video board, and ran WIndows XP SP2. The project went on smoothly and I never had suspicious errors.
Then I switched my system to an Asus P5K Premium, 4 gigs Ram, Intel QuadCore and an NVidia 8800 GTS, also running WIndows XP SP2. I am very meticulous when switching systems in middle of a development project and I pay particular attention to keeping the same softwareenvironment, down to updates and versions.It makes it easier to isolate changes due to hardware. With regards to the video, I quickly reverted back to the ATI 1950x because I was experiencing very slow BitBlits,occasional video IRQ lockups and, for the first time, the dreaded "GDI+ not initialized" error. Various reports on the Internetindicate that the NVidia 8800 GTS does not work properly (or at all, depending on the application) with a QuadCore cpu. So out with the NVidia (without much regrets -- there are many issues with the BIOS and the drivers) and back in with the old trusty ATI 1950x. Incidentally, I should also mention that I downloaded the latest BIOS for the motherboard, always a good idea when relatively new devices such as QuadCore cpus start entering the mainstream market.
But the "GDI+ not initialized" error has not gone. Here is a summary of my observations, in no particular order:
-
The error happens frequently when I am in Debug mode, as opposed to Release mode. As a matter of fact, I have not experienced it when I run the Release build.
-
Most of the time, the error will happen with the OpenFileDialog command, as reported by others in this forum
-
The error sometimes happens when trying to set the AntiAliasing mode in GDI+. In other words, the program succesfullyexecutes the OpenFileDialog, but will crash when setting AntiAlias. When examining the contents of the GDI pointer at the time of the AntiAlias call, I observed that all members of the structure were undefined. I.e. the pointer or the memory pointed at by the pointer were corrupted.
-
Sporadically, the GDI+ message is also accompanied by an Interop failure error message or a memory access violation message.
- What is most confusing is that if I rerun the Debug session immediately (without shutting down Visual Studio or rebooting), the program will run properly for a couple of runs. Then the error will reappear. And I am very careful to go through exactly the same steps on each run.
I am starting to get the feeling that the problem is due to the QuadCore, since I never had the problem on the DualCore system. The only hardware differences between the 2 systemsare the motherboard and the cpu. Either that, or there was a Windows update that tampered with the GDI+ threading.
Just as a matter of feedback, I was also running Tortoise CVS (version 2). I removed it after reading the messages in this forum. The removal did not change anything to the error condition. On the other hand, if this error is due to threading problems, the removal of one component in the shell may change the sequence of events sufficiently as to skirt the error condition. This would be consistent with the error in the "OpenFileDialog" since Tortoise inserts itself in that shell component.
So my two cents worth is that there is an event queueing or process synchronization issue at hand, which gets worse when four CPU's are present. In any case, it would be really really good if somebody at Microsoft had a closer look at the issue. Developing with this kind of Damoclean Sword hanging over one's head heightens insecurity and makes it a lot more difficult to separate the errors inherent to development from errors induced by lower system levels.
fcharp
| | fcharp Tuesday, April 01, 2008 6:48 PM | Following up on my own message.... Boy do I feel red in the face!!!!!!!!!! I did find the source of the problem and can confirm as others that Tortoise CVS was causing the problem. Seems that I had uninstalled Tortoise SVN but not CVS (!). Thank you all for your help.
| | fcharp Wednesday, April 02, 2008 10:47 PM | | | Peter Westerström Thursday, April 03, 2008 12:30 AM | I can confirm the bug report to TortoiseCVS gave result, it is now fixed in TortoiseCVS 1.10.6.
| | Peter Westerström Tuesday, April 08, 2008 6:53 PM | I was using TortoiseCVS 1.10.1 up to now. Fora couple of days, Visual Studio 2005 kept crashing regularly with this GDI+ error whenever I added some new file to the project. This was really disturbing. I had suspected corruptness of some internal project files (like intellisense, class wizard, etc.), but removing these files wouldn't help. I would never have guessed that the reason for the crash was the file selection box involved in adding the new files!
I installed TortoiseCVS 1.10.6 and can confirm that the bug has disappeared (at least, up to now ;-) whith that version.
So thank your very much everybody, you really helped me a lot!
Regards,
Matthias
| | msp0815 Friday, April 25, 2008 8:13 AM |
If found what was causing this bug in my case: Turtoise CVS 1.10.1 ( - 1.10.4).
Once Turtoiseis uninstalled, the OpenFileDialog works as normal. Older versions of Turtoise, 1.8.x work fine.
This have saved me plenty of time. This was the exact reason why I couldnt install Red Gates Profiler applications. My Turtoise CVS version is 1.10.5 .. or was :) Thanks! //Edsh | | Edsh Friday, September 11, 2009 5:54 PM |
|