2

My winforms project is throwing this error:

"Exception thrown: 'System.ComponentModel.Win32Exception' in System.Drawing.dll

Additional information: The operation completed successfully"

at this line:

this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));

The line is inside the auto generated code for the designer, so I'm not sure why it's throwing an error. I didn't edit it in any way, please help.

EDIT: this is not a duplicate, the other question is quite vague on the actual code.

EDIT #2: The error is now popping up at the designer of resources.resx, with the message

Parameter not valid

it now appears at this auto-generated code:

internal static System.Drawing.Bitmap WoodTex 
{
    get {
           object obj = ResourceManager.GetObject("WoodTex", resourceCulture);
           return ((System.Drawing.Bitmap)(obj));
        }
}

resourceCulture appears to be null, is this a different error entirely?

  • Possible duplicate of [System.ComponentModel.Win32Exception: The operation completed successfully](http://stackoverflow.com/questions/1209769/system-componentmodel-win32exception-the-operation-completed-successfully) – Ghasem Dec 28 '15 at 04:13
  • What is the value of resources.GetObject("$this.Icon")? Is it valid? – srandppl Dec 28 '15 at 05:00
  • I'm not sure OwlSolo, it's auto generated code from the designer. –  Dec 28 '15 at 05:13
  • This exception is not caused by the code you posted, it is caused by *other* code you wrote. The question is too vague to point the finger. But in general you are not using Dispose() and/or the *using* statement when you should, typically in Paint event handlers. Something you can troubleshoot with Task Manager, Processes tab. Add the GDI Objects and USER Objects columns. You'll see the number(s) steadily climbing for your program, the show is over when it reaches ten thousand. – Hans Passant Dec 28 '15 at 06:51
  • Thanks Hans, I still do not understand though, my program doesn't have more than two paint event handlers (it's full of files, so there might be more). I'm curious where I should use Dispose() and using statements though. –  Dec 28 '15 at 22:56

0 Answers0