specified cast is not valid.

  • Thread starter Thread starter Ansari
  • Start date Start date
A

Ansari

hi all,

I have a windows application which is developed in VB.NET.
I have used some bitmaps and set image property of button.
Some time I load form programmaticaly.. following error pops up

1) Specified Cast is not valid
it is on the following line of code.
Me.Button1.Image = CType(resources.GetObject("Button1.Image"),
System.Drawing.Bitmap).

To sovle this problem I CUT the button and paste it again and save project
next time i run it work fine....

What is the problem?



Ansari
 
Ansari,
Do you enable XP styles? If you do, check you have called DoEvents(). In
C#, something like this:

static void Main()
{
Application.EnableVisualStyles();
Application.DoEvents();
Application.Run(new MainForm());
}

Regards,
Phil.
 
Back
Top