Problem with adding icons to a imagelist on WM 2003 SE

G

Guest

I installed Windows Mobile 2003 Second Edition Emulator Images for Pocket PC. I then tried to start my application in the emulator and got the following error msg

An unhandled exception of type 'System.Exception' occurred in System.Windows.Forms.dl
Additional information: Exceptio

The problem occurs on the following line

iltToolbarButtons.Images.Add(New Icon(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("MyApp.ToolbarButton1.ico"))

'iltToolbarButtons' is a imagelist.

If I remove the line then the application starts without any problems. My application works fine on Pocket 2003. Anyone know why it fails to work on 2003 SE

Hel

Gavin
 
G

Guest

I am having the same problem. Failing on:
btnExLMP.Image = ImageListOb.Images[0];
ImageListOB is:
private System.Windows.Forms.ImageList ImageListOb = new System.Windows.Forms.ImageList();

This works in PPC2002 and PPC2003.
Regards,
Bill
 
P

Peter Bode Nielsen

I found this solution that worked for me.

OK here is the fix.=A0 The default code that works under every other Po=

cket

PC

OS won't work - you can't assign the image list to the toolbar in

InitializeComponent().=A0 Move the code somewhere else (Form_Load, etc)=

and

load the icons into the image list before assigning the imagelist to th=

e

toolbar.=A0 Then assign the image list to the toolbar.=A0 Then you have=

to

reassign the image index numbers to the toolbar buttons.=A0 Very

strange.......

Mike B.



I moved this code from form constructor to form_load:

this.toolBar1.ImageList =3D this.imageList1;

this.imageList1.Images.Add(GetIcon("name1"));

this.imageList1.Images.Add(GetIcon("name2"));

this.imageList1.Images.Add(GetIcon("name3"));

this.imageList1.Images.Add(GetIcon("name4"));

this.toolBar1.Buttons[0].ImageIndex = 0;

this.toolBar1.Buttons[1].ImageIndex = 1;

this.toolBar1.Buttons[2].ImageIndex = 2;

this.toolBar1.Buttons[3].ImageIndex = 3;



public static System.Drawing.Icon GetIcon(string name)

{

System.Reflection.Assembly execAssembly =3D

System.Reflection.Assembly.GetExecutingAssembly();

System.IO.Stream stream =3D

execAssembly.GetManifestResourceStream(execAssembly.GetName().Name + ".=

" +

name + ".ico");

return new System.Drawing.Icon(stream);

}

Hope this helps you......

balbert said:
I am having the same problem. Failing on:
btnExLMP.Image = ImageListOb.Images[0];
ImageListOB is:
private System.Windows.Forms.ImageList ImageListOb = new System.Windows.Forms.ImageList();

This works in PPC2002 and PPC2003.
Regards,
Bill

Bode said:
I am having exactly the same problem.............

Any help would be appreciated

Peter
Pocket PC. I then tried to start my application in the emulator and got the
following error msg:
Icon(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceSt
ream("MyApp.ToolbarButton1.ico")))
My application works fine on Pocket 2003. Anyone know why it fails to work
on 2003 SE?
 

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

Top