Invalid parameter used



I am facing a problem with my GDI++ code in C# control.

Though i have tried many things from last 6 months, i am not able to
get completely rid of this bug.

Whenever the user is opening a window or closing a window, i'm getting
following exception.

This is a very rare exception but it causes the whole application
and has become a nigtmare for me.

This problem is more frequent on Citrix client as compared to normal
desktop environment.

InnnerException: Invalid parameter used.

Stack Trace: at System.Drawing.Region.GetHrgn(Graphics g)
at System.Windows.Forms.Control.GetHRgn(Region region)
at System.Windows.Forms.Control.OnHandleCreated(EventArgs e)
at System.Windows.Forms.Control.WmCreate(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32
msg, IntPtr wparam, IntPtr lparam)
Source: System.Drawing

I have done following coding in a control which is derived from

protected override void OnPaint(PaintEventArgs e)
if(this != null)
if(!this.IsDisposed && !this.Disposing)
using(GraphicsPath path = new
path.AddEllipse(0, 0, this.Width, this.Height);
using(Region rgn = new Region(path).Clone())


I'll appriciate if you can provide some help.




You posted this to at least the following newsgroups:


but not to


When you post a message to multiple groups, please post all of
them at once. That way, if someone in one group provides a
solution, the solution will be posted to all of the groups.
Also, if someone in another group is working on a solution,
they will know it has been solved, and they can work on helping
somebody else.

Also please do not post to newsgroups that are not pertinent,
like in this case, the VB newsgroups, when you have a C# issue.

Robin S.

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question