VS 2005 Designer issue

D

dantheman

Hi All,

here it goes,

I have created a usercontrol "image button" and it all work fine except
for one strange thing, when i drag the control to a form "smart device
that is" and then save that form i get this error

Code generation for property 'Image' failed.
Error was: 'Object reference not set to an instance of an object.'

this only happends the first time i drag the control to a form and save
the form after that error if add more controls other then my image
button i save again it's ok

in the property designer the image property is set to (none)

now if in my constructor i had this line
this.image = new Bitmap(21, 21);
it all works ok

any idea y this is appening
 
T

Tim Wilson

Are you attempting to utilize the Image property, or the "image" field
behind the property, from anywhere within your custom control while it's
still "null"? In other words, have you gone through the source for your
control to ensure that no attempt is made to access the image object while
it is still set to "null".
 

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