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!

System.NullReferenceException

Status
Not open for further replies.

dolfo35

Programmer
Jan 26, 2001
28
US
Has anyone ever encountered anything similar to this? I have a Tab Control on a Windows Form. Currently, it has 8 Tab Pages. On the eighth tab I have 2 DateTimePickers and one Button. I'm trying to add another control to this tab. I need to add a datagrid, but in trying to solve this problem I've come to realize that it happens with any control.

So, when I add another control and run the program I get the NullReferenceException error. I get it regardless if I've changed any properties. I stop the debugger and run the program again and it runs fine. I can run the program 100 times and every other time I will get the error. Does anyone have any idea what could be causing this?

Thanks in advance.
Rudy
 
How many projects are in your solution? There is a way to have 2 projects that reference eachother, this can lead to an 'every other time' failure as 1 file is waiting for the other to finish compiling.

-Rick

VB.Net Forum forum796 forum855 ASP.NET Forum
[monkey]I believe in killer coding ninja monkeys.[monkey]
 
Rick, the only other project is the deployment project. I can try removing that tomorrow at work and see if that makes a difference.

Thanks for the quick reply.
Rudy
 
Rick,

Thanks for that suggestion. I removed the install project and the problem still exists. As soon as I added the control it worked the first time and then got the NullReference every time after that. Maybe that's a good thing that it's not happening every other time anymore.

If the main project, I have 4 forms and one module. What I don't understand is why it's doing it at this point. I have seven other tabs with many controls. It's almost as if there is a limit on how many controls can be handled by a tab control or a form.

Please let me know if you have any other ideas. In the meantime I have no choice but to continue researching it. I can't go to the next step until I get this one completed.

Thanks again,
Rudy
 
No, after I hit Break on the error box I get another that says "There is no source code available for the current location."

Rudy
 
Yes, Component1 controls all throughout the project. Not on this particular tab though. One on the main form and then some more on other tabs.

Rudy
 
One of the problems with the tabcontrol is that it is very buggy. And most of the tie you will have to learn to life with it or look for another component that does the sam ething but different. I like the form in form aproach but only when everything else fails.

Christiaan Baes
Belgium

If you want to get an answer read this FAQ faq796-2540
There's no such thing as a winnable war - Sting
 
I haven't used the tab control much. At the moment I have a dynamically loading panel. Each module in my app has a user control which is just a panel with the input controls for that module. When the user select the module from the tree view, the display panel is cleared and loads the new user control.

Not quite the same purpose as a tab control, but you could use a similar method to create your own user control to replace the tab control.

-Rick

VB.Net Forum forum796 forum855 ASP.NET Forum
[monkey]I believe in killer coding ninja monkeys.[monkey]
 
Your exception object will have a stack trace attached to it. You can examine that to find the last point where the call history was in your code (as opposed to deep in the framework code).

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
Well, I did not figure out what the problem was. I did figure out that when I build the Install project, install it on my computer, and run the application, there is no interruption. That is true for this project. I'm not sure that I won't see the NullReference in future projects. It's annoying, but if it doesn't affect the final program then I'm okay in the long run.

Thank you all for your input.
Rudy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top