Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can't track this error

Status
Not open for further replies.

keyser456

IS-IT--Management
Nov 21, 2003
73
US
I have a custom control that is acting like an MS Access subform. When I modify a new record, it is supposed to add a new blank record to the subform, just like MS Access does (in the subform the record has a * indicating it is a new and blank record).

In my project, if I modify a text box and tab out to or click on another field in the same record, a new blank record is added successfully to my subform (which is exactly how I want it to work). However, if I modify the text box and click or tab anywhere outside the newly modifed subform record I get an error:

Object reference not set to an instance of an object.

For the life of me I can't track down this error. If I set breakpoints at all the relevant spots I can step through every single line until the call stack only has "Non-user Code" and the main entry point, and then it throws the error.

I do know that if I REM out one line (a procedure call) the error does not occur. However, if I UNREM the line and step through each line it runs fine until the "Non-user Code" at which point the error occurs and the debugger shows me the ending curly brace for my Main() entry point.

I need a better way to figure out exactly where this error is being thrown. I'm trying to figure out if the locals window can be of any help, but I guess I don't know exactly where to look. The stacktrace has a bunch of stuff in it, but it seems like its all internal to .NET so I really can't see what's going wrong.

Any suggestions?
 
maybe post the code of the procedure that throws this exception

--------------------------
"two wrongs don't make a right, but three lefts do" - the unknown sage
 
Umm... see, that's the problem. It's thrown in Non-User code. The final line in the Call Stack shows ValidateThroughAncestor which is a method of ContainerControl, but I don't have the code for that procedure because it is internal to .NET.

Anyway, I think I have a general idea of what is going wrong (disposing of a control when an event tied to the control fires), and have a workaround in mind. It just seems odd that Visual Studio and .NET didn't make the cause of the error more clear. All I got was NullReferenceException: Object reference not set to an instance... Very informative, eh?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top