imagelist won't work in specific project

M

mgarner1980

Hi,

I have a somewhat substantial project that won't let me add an imagelist
(with images that is) to any form without throwing a null refference
exception when trying to run the following lines of code (added by IDE).

Me.ImageList1.Images.Add(CType(resources.GetObject("resource"),
System.Drawing.Image))


I can create a new project ....add a form ... add an imagelist in exactly
the same fashion....and it works as if should.

Any ideas as to why this project is giving me fits with imagelists?

BTW.....It's written in VB.net
 
D

Daniel Moth

Is there already another ImageList on the form?
Where does ImageList1 get created?
It throws with existing forms in that project; does it throw if you add it
to a *new* form in that project?
Does it throw when you add an ImageList from the toolbar and populate it
(rather than adding a pre-populated one)?
What are the values of each element of that line prior to the exception?
[put a breakpoint on the line and step into]

Cheers
Daniel
 
M

mgarner1980

1) nope....no other imagelist on form or anywhere in project.
2)I dropped a imagelist control onto form and added images through the
collection editor in the IDE.
3)I does throw if I add new form and add imagelist to it.
5) this is the null object from what I can tell:
resources.GetObject("resource")
it returns :nothing".

4)I'm not sure what you mean by adding from toolbar and populatiung it
(rather than adding pre-populated one)
If I add one with no images added to it, it doesn't throw (if that's what
you mean).

Daniel Moth said:
Is there already another ImageList on the form?
Where does ImageList1 get created?
It throws with existing forms in that project; does it throw if you add it
to a *new* form in that project?
Does it throw when you add an ImageList from the toolbar and populate it
(rather than adding a pre-populated one)?
What are the values of each element of that line prior to the exception?
[put a breakpoint on the line and step into]

Cheers
Daniel
--
http://www.danielmoth.com/Blog/


mgarner1980 said:
Hi,

I have a somewhat substantial project that won't let me add an imagelist
(with images that is) to any form without throwing a null refference
exception when trying to run the following lines of code (added by IDE).

Me.ImageList1.Images.Add(CType(resources.GetObject("resource"),
System.Drawing.Image))


I can create a new project ....add a form ... add an imagelist in exactly
the same fashion....and it works as if should.

Any ideas as to why this project is giving me fits with imagelists?

BTW.....It's written in VB.net
 
D

Daniel Moth

OK, it sounds like it cannot find "resource".

You said you add images; can you try with a single image at a time to see
which one is the culprit?

Also by calling assembly.GetManifestResourceNames you can find out which
resources it *does* know about.

Worst case scenario, add your images as embedded resources to the project
and then manually add them to the ImageList (or other target control)
programmatically

Cheers
Daniel
--
http://www.danielmoth.com/Blog/


mgarner1980 said:
1) nope....no other imagelist on form or anywhere in project.
2)I dropped a imagelist control onto form and added images through the
collection editor in the IDE.
3)I does throw if I add new form and add imagelist to it.
5) this is the null object from what I can tell:
resources.GetObject("resource")
it returns :nothing".

4)I'm not sure what you mean by adding from toolbar and populatiung it
(rather than adding pre-populated one)
If I add one with no images added to it, it doesn't throw (if that's what
you mean).

Daniel Moth said:
Is there already another ImageList on the form?
Where does ImageList1 get created?
It throws with existing forms in that project; does it throw if you add
it
to a *new* form in that project?
Does it throw when you add an ImageList from the toolbar and populate it
(rather than adding a pre-populated one)?
What are the values of each element of that line prior to the exception?
[put a breakpoint on the line and step into]

Cheers
Daniel
--
http://www.danielmoth.com/Blog/


mgarner1980 said:
Hi,

I have a somewhat substantial project that won't let me add an
imagelist
(with images that is) to any form without throwing a null refference
exception when trying to run the following lines of code (added by
IDE).

Me.ImageList1.Images.Add(CType(resources.GetObject("resource"),
System.Drawing.Image))


I can create a new project ....add a form ... add an imagelist in exactly
the same fashion....and it works as if should.

Any ideas as to why this project is giving me fits with imagelists?

BTW.....It's written in VB.net
 
M

mgarner1980

I'm trying to add them programmatically now.

here's what I'm trying (it returns nothing also)
Dim bmp As New
Bitmap([Assembly].GetExecutingAssembly().GetManifestResourceStream("allmidap
sdbreplflexgrid.anchor.bmp"))

I've seen several samples of this that work fine (some of them are loaded on
my machine). But I cannot get them to work for myself for some reason.





Daniel Moth said:
OK, it sounds like it cannot find "resource".

You said you add images; can you try with a single image at a time to see
which one is the culprit?

Also by calling assembly.GetManifestResourceNames you can find out which
resources it *does* know about.

Worst case scenario, add your images as embedded resources to the project
and then manually add them to the ImageList (or other target control)
programmatically

Cheers
Daniel
--
http://www.danielmoth.com/Blog/


mgarner1980 said:
1) nope....no other imagelist on form or anywhere in project.
2)I dropped a imagelist control onto form and added images through the
collection editor in the IDE.
3)I does throw if I add new form and add imagelist to it.
5) this is the null object from what I can tell:
resources.GetObject("resource")
it returns :nothing".

4)I'm not sure what you mean by adding from toolbar and populatiung it
(rather than adding pre-populated one)
If I add one with no images added to it, it doesn't throw (if that's what
you mean).

Daniel Moth said:
Is there already another ImageList on the form?
Where does ImageList1 get created?
It throws with existing forms in that project; does it throw if you add
it
to a *new* form in that project?
Does it throw when you add an ImageList from the toolbar and populate it
(rather than adding a pre-populated one)?
What are the values of each element of that line prior to the exception?
[put a breakpoint on the line and step into]

Cheers
Daniel
--
http://www.danielmoth.com/Blog/


Hi,

I have a somewhat substantial project that won't let me add an
imagelist
(with images that is) to any form without throwing a null refference
exception when trying to run the following lines of code (added by
IDE).

Me.ImageList1.Images.Add(CType(resources.GetObject("resource"),
System.Drawing.Image))


I can create a new project ....add a form ... add an imagelist in exactly
the same fashion....and it works as if should.

Any ideas as to why this project is giving me fits with imagelists?

BTW.....It's written in VB.net
 
M

mgarner1980

I'm also trying to add it in code like this. This also returns nothing. The
file is added as embedded resource to project allmidapsdbreplflexgrid.

Dim bmp As New
Bitmap([Assembly].GetExecutingAssembly().GetManifestResourceStream("allmidap
sdbreplflexgrid.anchor.bmp"))

Daniel Moth said:
OK, it sounds like it cannot find "resource".

You said you add images; can you try with a single image at a time to see
which one is the culprit?

Also by calling assembly.GetManifestResourceNames you can find out which
resources it *does* know about.

Worst case scenario, add your images as embedded resources to the project
and then manually add them to the ImageList (or other target control)
programmatically

Cheers
Daniel
--
http://www.danielmoth.com/Blog/


mgarner1980 said:
1) nope....no other imagelist on form or anywhere in project.
2)I dropped a imagelist control onto form and added images through the
collection editor in the IDE.
3)I does throw if I add new form and add imagelist to it.
5) this is the null object from what I can tell:
resources.GetObject("resource")
it returns :nothing".

4)I'm not sure what you mean by adding from toolbar and populatiung it
(rather than adding pre-populated one)
If I add one with no images added to it, it doesn't throw (if that's what
you mean).

Daniel Moth said:
Is there already another ImageList on the form?
Where does ImageList1 get created?
It throws with existing forms in that project; does it throw if you add
it
to a *new* form in that project?
Does it throw when you add an ImageList from the toolbar and populate it
(rather than adding a pre-populated one)?
What are the values of each element of that line prior to the exception?
[put a breakpoint on the line and step into]

Cheers
Daniel
--
http://www.danielmoth.com/Blog/


Hi,

I have a somewhat substantial project that won't let me add an
imagelist
(with images that is) to any form without throwing a null refference
exception when trying to run the following lines of code (added by
IDE).

Me.ImageList1.Images.Add(CType(resources.GetObject("resource"),
System.Drawing.Image))


I can create a new project ....add a form ... add an imagelist in exactly
the same fashion....and it works as if should.

Any ideas as to why this project is giving me fits with imagelists?

BTW.....It's written in VB.net
 
D

Daniel Moth

8 out of 10 it is a problem with not passing the name correctly (missing a
namespace or folder name).

Have you tried as per previous suggestion to call
assembly.GetManifestResourceNames? This will tell you the exact names you
have to use.

Cheers
Daniel
--
http://www.danielmoth.com/Blog/


mgarner1980 said:
I'm also trying to add it in code like this. This also returns nothing.
The
file is added as embedded resource to project allmidapsdbreplflexgrid.

Dim bmp As New
Bitmap([Assembly].GetExecutingAssembly().GetManifestResourceStream("allmidap
sdbreplflexgrid.anchor.bmp"))

Daniel Moth said:
OK, it sounds like it cannot find "resource".

You said you add images; can you try with a single image at a time to see
which one is the culprit?

Also by calling assembly.GetManifestResourceNames you can find out which
resources it *does* know about.

Worst case scenario, add your images as embedded resources to the project
and then manually add them to the ImageList (or other target control)
programmatically

Cheers
Daniel
--
http://www.danielmoth.com/Blog/


mgarner1980 said:
1) nope....no other imagelist on form or anywhere in project.
2)I dropped a imagelist control onto form and added images through the
collection editor in the IDE.
3)I does throw if I add new form and add imagelist to it.
5) this is the null object from what I can tell:
resources.GetObject("resource")
it returns :nothing".

4)I'm not sure what you mean by adding from toolbar and populatiung it
(rather than adding pre-populated one)
If I add one with no images added to it, it doesn't throw (if that's what
you mean).

Is there already another ImageList on the form?
Where does ImageList1 get created?
It throws with existing forms in that project; does it throw if you
add
it
to a *new* form in that project?
Does it throw when you add an ImageList from the toolbar and populate it
(rather than adding a pre-populated one)?
What are the values of each element of that line prior to the exception?
[put a breakpoint on the line and step into]

Cheers
Daniel
--
http://www.danielmoth.com/Blog/


Hi,

I have a somewhat substantial project that won't let me add an
imagelist
(with images that is) to any form without throwing a null refference
exception when trying to run the following lines of code (added by
IDE).

Me.ImageList1.Images.Add(CType(resources.GetObject("resource"),
System.Drawing.Image))


I can create a new project ....add a form ... add an imagelist in
exactly
the same fashion....and it works as if should.

Any ideas as to why this project is giving me fits with imagelists?

BTW.....It's written in VB.net
 
M

mgarner1980

Ok, you were right...I figured oit what to call them using
getmanifestresourcenames.....thanks.

Any idea or suggestions as to why the preloaded ones aren't working (only
in this project)?

Thanks again
Daniel Moth said:
8 out of 10 it is a problem with not passing the name correctly (missing a
namespace or folder name).

Have you tried as per previous suggestion to call
assembly.GetManifestResourceNames? This will tell you the exact names you
have to use.

Cheers
Daniel
--
http://www.danielmoth.com/Blog/


mgarner1980 said:
I'm also trying to add it in code like this. This also returns nothing.
The
file is added as embedded resource to project allmidapsdbreplflexgrid.

Dim bmp As New
Bitmap([Assembly].GetExecutingAssembly().GetManifestResourceStream("allmidap
sdbreplflexgrid.anchor.bmp"))

Daniel Moth said:
OK, it sounds like it cannot find "resource".

You said you add images; can you try with a single image at a time to see
which one is the culprit?

Also by calling assembly.GetManifestResourceNames you can find out which
resources it *does* know about.

Worst case scenario, add your images as embedded resources to the project
and then manually add them to the ImageList (or other target control)
programmatically

Cheers
Daniel
--
http://www.danielmoth.com/Blog/


1) nope....no other imagelist on form or anywhere in project.
2)I dropped a imagelist control onto form and added images through the
collection editor in the IDE.
3)I does throw if I add new form and add imagelist to it.
5) this is the null object from what I can tell:
resources.GetObject("resource")
it returns :nothing".

4)I'm not sure what you mean by adding from toolbar and populatiung it
(rather than adding pre-populated one)
If I add one with no images added to it, it doesn't throw (if that's what
you mean).

Is there already another ImageList on the form?
Where does ImageList1 get created?
It throws with existing forms in that project; does it throw if you
add
it
to a *new* form in that project?
Does it throw when you add an ImageList from the toolbar and
populate
it
(rather than adding a pre-populated one)?
What are the values of each element of that line prior to the exception?
[put a breakpoint on the line and step into]

Cheers
Daniel
--
http://www.danielmoth.com/Blog/


Hi,

I have a somewhat substantial project that won't let me add an
imagelist
(with images that is) to any form without throwing a null refference
exception when trying to run the following lines of code (added by
IDE).

Me.ImageList1.Images.Add(CType(resources.GetObject("resource"),
System.Drawing.Image))


I can create a new project ....add a form ... add an imagelist in
exactly
the same fashion....and it works as if should.

Any ideas as to why this project is giving me fits with imagelists?

BTW.....It's written in VB.net
 
D

Daniel Moth

Not without debugging it.... You could go back and add them to the ImageList
and use the getmanifestresourcenames approach to see where it goes wrong...
or try one image at a time to see which one is problematic (different sizes
perhaps).. etc.. debugging it...

Glad you got it working

Cheers
Daniel
--
http://www.danielmoth.com/Blog/


mgarner1980 said:
Ok, you were right...I figured oit what to call them using
getmanifestresourcenames.....thanks.

Any idea or suggestions as to why the preloaded ones aren't working (only
in this project)?

Thanks again
Daniel Moth said:
8 out of 10 it is a problem with not passing the name correctly (missing
a
namespace or folder name).

Have you tried as per previous suggestion to call
assembly.GetManifestResourceNames? This will tell you the exact names you
have to use.

Cheers
Daniel
--
http://www.danielmoth.com/Blog/


mgarner1980 said:
I'm also trying to add it in code like this. This also returns nothing.
The
file is added as embedded resource to project allmidapsdbreplflexgrid.

Dim bmp As New
Bitmap([Assembly].GetExecutingAssembly().GetManifestResourceStream("allmidap
sdbreplflexgrid.anchor.bmp"))

OK, it sounds like it cannot find "resource".

You said you add images; can you try with a single image at a time to see
which one is the culprit?

Also by calling assembly.GetManifestResourceNames you can find out which
resources it *does* know about.

Worst case scenario, add your images as embedded resources to the project
and then manually add them to the ImageList (or other target control)
programmatically

Cheers
Daniel
--
http://www.danielmoth.com/Blog/


1) nope....no other imagelist on form or anywhere in project.
2)I dropped a imagelist control onto form and added images through the
collection editor in the IDE.
3)I does throw if I add new form and add imagelist to it.
5) this is the null object from what I can tell:
resources.GetObject("resource")
it returns :nothing".

4)I'm not sure what you mean by adding from toolbar and populatiung it
(rather than adding pre-populated one)
If I add one with no images added to it, it doesn't throw (if that's
what
you mean).

Is there already another ImageList on the form?
Where does ImageList1 get created?
It throws with existing forms in that project; does it throw if you
add
it
to a *new* form in that project?
Does it throw when you add an ImageList from the toolbar and populate
it
(rather than adding a pre-populated one)?
What are the values of each element of that line prior to the
exception?
[put a breakpoint on the line and step into]

Cheers
Daniel
--
http://www.danielmoth.com/Blog/


Hi,

I have a somewhat substantial project that won't let me add an
imagelist
(with images that is) to any form without throwing a null refference
exception when trying to run the following lines of code (added
by
IDE).

Me.ImageList1.Images.Add(CType(resources.GetObject("resource"),
System.Drawing.Image))


I can create a new project ....add a form ... add an imagelist in
exactly
the same fashion....and it works as if should.

Any ideas as to why this project is giving me fits with imagelists?

BTW.....It's written in VB.net
 
M

mgarner1980

I did already debug it. It's trying to use "reource" and
"resource1".....neither of which are in the manifest list. there are howver
13 items in the resourcelist. I guess the collection editor isn't smart
enough to keep track of everything?

Thanks again for you quick replies...you've been a great help.
Daniel Moth said:
Not without debugging it.... You could go back and add them to the ImageList
and use the getmanifestresourcenames approach to see where it goes wrong...
or try one image at a time to see which one is problematic (different sizes
perhaps).. etc.. debugging it...

Glad you got it working

Cheers
Daniel
--
http://www.danielmoth.com/Blog/


mgarner1980 said:
Ok, you were right...I figured oit what to call them using
getmanifestresourcenames.....thanks.

Any idea or suggestions as to why the preloaded ones aren't working (only
in this project)?

Thanks again
Daniel Moth said:
8 out of 10 it is a problem with not passing the name correctly (missing
a
namespace or folder name).

Have you tried as per previous suggestion to call
assembly.GetManifestResourceNames? This will tell you the exact names you
have to use.

Cheers
Daniel
--
http://www.danielmoth.com/Blog/


I'm also trying to add it in code like this. This also returns nothing.
The
file is added as embedded resource to project allmidapsdbreplflexgrid.

Dim bmp As New
Bitmap([Assembly].GetExecutingAssembly().GetManifestResourceStream("allmidap
sdbreplflexgrid.anchor.bmp"))

OK, it sounds like it cannot find "resource".

You said you add images; can you try with a single image at a time
to
see
which one is the culprit?

Also by calling assembly.GetManifestResourceNames you can find out which
resources it *does* know about.

Worst case scenario, add your images as embedded resources to the project
and then manually add them to the ImageList (or other target control)
programmatically

Cheers
Daniel
--
http://www.danielmoth.com/Blog/


1) nope....no other imagelist on form or anywhere in project.
2)I dropped a imagelist control onto form and added images through the
collection editor in the IDE.
3)I does throw if I add new form and add imagelist to it.
5) this is the null object from what I can tell:
resources.GetObject("resource")
it returns :nothing".

4)I'm not sure what you mean by adding from toolbar and
populatiung
it
(rather than adding pre-populated one)
If I add one with no images added to it, it doesn't throw (if that's
what
you mean).

Is there already another ImageList on the form?
Where does ImageList1 get created?
It throws with existing forms in that project; does it throw if you
add
it
to a *new* form in that project?
Does it throw when you add an ImageList from the toolbar and populate
it
(rather than adding a pre-populated one)?
What are the values of each element of that line prior to the
exception?
[put a breakpoint on the line and step into]

Cheers
Daniel
--
http://www.danielmoth.com/Blog/


Hi,

I have a somewhat substantial project that won't let me add an
imagelist
(with images that is) to any form without throwing a null refference
exception when trying to run the following lines of code (added
by
IDE).

Me.ImageList1.Images.Add(CType(resources.GetObject("resource"),
System.Drawing.Image))


I can create a new project ....add a form ... add an imagelist in
exactly
the same fashion....and it works as if should.

Any ideas as to why this project is giving me fits with imagelists?

BTW.....It's written in VB.net
 
D

Daniel Moth

Actually strike the comment about using getmanifestresourcenames when adding
them to the ImageList. The names are actually in the resx file (if you show
all files, the one under the form1.vb). I still don't know why it doesn't
work for you. It does over here, so it must be something to do with the
specific images. What are they (bmps, jpg) and what size?

The point is that the approach that worked for you is the one I personally
prefer and use.

Cheers
Daniel
--
http://www.danielmoth.com/Blog/


mgarner1980 said:
I did already debug it. It's trying to use "reource" and
"resource1".....neither of which are in the manifest list. there are
howver
13 items in the resourcelist. I guess the collection editor isn't smart
enough to keep track of everything?

Thanks again for you quick replies...you've been a great help.
Daniel Moth said:
Not without debugging it.... You could go back and add them to the ImageList
and use the getmanifestresourcenames approach to see where it goes wrong...
or try one image at a time to see which one is problematic (different sizes
perhaps).. etc.. debugging it...

Glad you got it working

Cheers
Daniel
--
http://www.danielmoth.com/Blog/


mgarner1980 said:
Ok, you were right...I figured oit what to call them using
getmanifestresourcenames.....thanks.

Any idea or suggestions as to why the preloaded ones aren't working (only
in this project)?

Thanks again
8 out of 10 it is a problem with not passing the name correctly (missing
a
namespace or folder name).

Have you tried as per previous suggestion to call
assembly.GetManifestResourceNames? This will tell you the exact names you
have to use.

Cheers
Daniel
--
http://www.danielmoth.com/Blog/


I'm also trying to add it in code like this. This also returns nothing.
The
file is added as embedded resource to project allmidapsdbreplflexgrid.

Dim bmp As New

Bitmap([Assembly].GetExecutingAssembly().GetManifestResourceStream("allmidap
sdbreplflexgrid.anchor.bmp"))

OK, it sounds like it cannot find "resource".

You said you add images; can you try with a single image at a time to
see
which one is the culprit?

Also by calling assembly.GetManifestResourceNames you can find out
which
resources it *does* know about.

Worst case scenario, add your images as embedded resources to the
project
and then manually add them to the ImageList (or other target control)
programmatically

Cheers
Daniel
--
http://www.danielmoth.com/Blog/


1) nope....no other imagelist on form or anywhere in project.
2)I dropped a imagelist control onto form and added images
through
the
collection editor in the IDE.
3)I does throw if I add new form and add imagelist to it.
5) this is the null object from what I can tell:
resources.GetObject("resource")
it returns :nothing".

4)I'm not sure what you mean by adding from toolbar and populatiung
it
(rather than adding pre-populated one)
If I add one with no images added to it, it doesn't throw (if that's
what
you mean).

Is there already another ImageList on the form?
Where does ImageList1 get created?
It throws with existing forms in that project; does it throw if you
add
it
to a *new* form in that project?
Does it throw when you add an ImageList from the toolbar and
populate
it
(rather than adding a pre-populated one)?
What are the values of each element of that line prior to the
exception?
[put a breakpoint on the line and step into]

Cheers
Daniel
--
http://www.danielmoth.com/Blog/


Hi,

I have a somewhat substantial project that won't let me add an
imagelist
(with images that is) to any form without throwing a null
refference
exception when trying to run the following lines of code
(added
by
IDE).

Me.ImageList1.Images.Add(CType(resources.GetObject("resource"),
System.Drawing.Image))


I can create a new project ....add a form ... add an imagelist in
exactly
the same fashion....and it works as if should.

Any ideas as to why this project is giving me fits with
imagelists?

BTW.....It's written in VB.net
 

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