473,473 Members | 2,193 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Error deleting control

Hi,

I have created a custom button control, descended from ButtonBase, which
implements custom drawing etc.

Everything works fine, until I try to delete the button from the form in
the designer. At this point I get the message 'Object Reference not set
to an Instance of an Object'

My Dispose function is very simple, as it just deletes a bitmap object
(after checking it is not null) and then calls base.Dispose()

I know what the error means, but because it is occurring while in design
mode, I don't know how to find out what's causing it.

Can anyone suggest something to look for, or any events that might be
fired while the object is being disposed of, or even a way to debug it
in design mode?
Can anyone tell me where and when the Disposing flag gets set?
I am using c# in VS 2003 and .Net 1.1
Thankyou.

Paul
Mar 8 '06 #1
2 1345
Paul,

You can debug the design time:

1. Open the VS studio and load your project. I'll call it VS1
2. Open a new VS instance and create a new test project where you are going
to use your new control. I'll call this VS2
3. In VS1 set break points on the method(s) you want to debug
4. In VS1 from the Debug menu chose "Attach to Process..." command
5. In the dialog box find the process for VS2 (it is called devenv BTW; it
shows also the caption bar text so you can find it easily)
6. Attach to VS2 process
7. Start using VS2 - add the control to a form, remove it from a form, etc.
VS one will stop on the brak points and you will be able to debug your
probelem.

FYI there are more than one way how to do the debugging basically the goal
is the same to start another instance of VS and attach to its process.
Personally I found the steps I gave you the most convinient to use.
--
HTH
Stoitcho Goutsev (100)
"Paul Cheetham" <PA******@dsl.pipex.com> wrote in message
news:eh**************@tk2msftngp13.phx.gbl...
Hi,

I have created a custom button control, descended from ButtonBase, which
implements custom drawing etc.

Everything works fine, until I try to delete the button from the form in
the designer. At this point I get the message 'Object Reference not set to
an Instance of an Object'

My Dispose function is very simple, as it just deletes a bitmap object
(after checking it is not null) and then calls base.Dispose()

I know what the error means, but because it is occurring while in design
mode, I don't know how to find out what's causing it.

Can anyone suggest something to look for, or any events that might be
fired while the object is being disposed of, or even a way to debug it in
design mode?
Can anyone tell me where and when the Disposing flag gets set?
I am using c# in VS 2003 and .Net 1.1
Thankyou.

Paul

Mar 8 '06 #2


Thankyou for your help.
I managed to find it in the end - my OnParentChanged event handler was
being called, and the EventArgs parameter was null.

Thanks again.

Paul


Stoitcho Goutsev (100) wrote:
Paul,

You can debug the design time:

1. Open the VS studio and load your project. I'll call it VS1
2. Open a new VS instance and create a new test project where you are going
to use your new control. I'll call this VS2
3. In VS1 set break points on the method(s) you want to debug
4. In VS1 from the Debug menu chose "Attach to Process..." command
5. In the dialog box find the process for VS2 (it is called devenv BTW; it
shows also the caption bar text so you can find it easily)
6. Attach to VS2 process
7. Start using VS2 - add the control to a form, remove it from a form, etc.
VS one will stop on the brak points and you will be able to debug your
probelem.

FYI there are more than one way how to do the debugging basically the goal
is the same to start another instance of VS and attach to its process.
Personally I found the steps I gave you the most convinient to use.

Mar 8 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: David Webb | last post by:
The problem started when the Working Folder for a project was somehow set to the folder of another project. I set the correct working folder in VSS and deleted the .vbproj files that had been...
1
by: Mark | last post by:
Not sure this is the right place for this questions, but here goes: I get an error message when deleting an table from a Access database. The code is as follows and the error message is after...
4
by: Mark | last post by:
Not sure this is the right place for this questions, but here goes: I get an error message when deleting an table from a Access database. The code is as follows and the error message is after...
4
by: pshindle | last post by:
DB2 Team - I just downloaded and unzipped the new Fixpack 9 for DB2 ESE V8 for Windows (FP9_WR21350_ESE.exe). I then burned the unzipped Fixpack files to a CD. I proceded to install this...
8
by: Steve | last post by:
I have several pairs of synchronized subforms in an application. I have a Delete button for each pair that uses the following code or similar to delete a record in the second subform: ...
1
by: Richard Roche | last post by:
How can i find where this 'parser error' is coming from. It works find in prodution and but now fail in test. I've done this many many times, but have not seem this. ...
1
by: Mark | last post by:
Not sure this is the right place for this questions, but here goes: I get an error message when deleting an table from a Access database. The code is as follows and the error message is after...
5
by: Patrick Vanden Driessche | last post by:
Hi All, I'm currently writing an in-house Form validation framework (WinForms) which is based on 'Component'-inheriting object. So basically, I have a small hierarchy. FormValidator +--...
5
by: John Veldthuis | last post by:
My code works perfectly 100% when adding items to my ArrayList and updating the listbox. Works perfectly when deleting an item in the ArrayList when it is not the last entry but if it is the last...
1
by: John Dalberg | last post by:
Running VS 2005 SP1. I am getting errors on pages which contain custom controls. A typical error looks like this: (This is from a test aspx page which only contains the custom control) Parser...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.