473,408 Members | 1,743 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Error Handling

I got this error in my programm
how do i skip this error? thax

An unhandled exception of
type 'System.NullReferenceException' occurred in
system.windows.forms.dll

Additional information: Object reference not set to an
instance of an object.

Nov 16 '05 #1
5 1807
Hi,

It would be much easier if you posted the line where you get this error.

--
Regards,
Peter Jausovec
(http://blog.jausovec.net)
"Kimochi" <an*******@discussions.microsoft.com> je napisal v sporocilo
news:1a****************************@phx.gbl ...
I got this error in my programm
how do i skip this error? thax

An unhandled exception of
type 'System.NullReferenceException' occurred in
system.windows.forms.dll

Additional information: Object reference not set to an
instance of an object.

Nov 16 '05 #2
try
{
// The offending code here.
}
catch(NullReferenceException)
{
}

--
Sincerely,
Dmitriy Lapshin [C# / .NET MVP]
Bring the power of unit testing to the VS .NET IDE today!
http://www.x-unity.net/teststudio.aspx

"Kimochi" <an*******@discussions.microsoft.com> wrote in message
news:1a****************************@phx.gbl...
I got this error in my programm
how do i skip this error? thax

An unhandled exception of
type 'System.NullReferenceException' occurred in
system.windows.forms.dll

Additional information: Object reference not set to an
instance of an object.


Nov 16 '05 #3
this is my code

private void menuItem1_Click(object sender,
System.EventArgs e)
{
MessageBox.Show(ActiveMdiChild.Text);
}

ihave this function in my menu
it works if one of the form is open or active
if none of the child form is active it will prompt the
error. how do i handle it?
Nov 16 '05 #4
Perhaps, you can check whether any child form is active before accessing it:

if (ActiveMdiChild == null)
MessageBox.Show ("No active MDI child");
else
MessageBox.Show(ActiveMdiChild.Text);

<an*******@discussions.microsoft.com> wrote in message
news:0d****************************@phx.gbl...
this is my code

private void menuItem1_Click(object sender,
System.EventArgs e)
{
MessageBox.Show(ActiveMdiChild.Text);
}

ihave this function in my menu
it works if one of the form is open or active
if none of the child form is active it will prompt the
error. how do i handle it?
Nov 16 '05 #5
I have try that before but still cannot works
anyway ive try the

try and catch and it can skip the errors

thax you for the help
-----Original Message-----
Perhaps, you can check whether any child form is active before accessing it:
if (ActiveMdiChild == null)
MessageBox.Show ("No active MDI child");
else
MessageBox.Show(ActiveMdiChild.Text);

<an*******@discussions.microsoft.com> wrote in message
news:0d****************************@phx.gbl...
this is my code

private void menuItem1_Click(object sender,
System.EventArgs e)
{
MessageBox.Show(ActiveMdiChild.Text);
}

ihave this function in my menu
it works if one of the form is open or active
if none of the child form is active it will prompt the
error. how do i handle it?
.

Nov 16 '05 #6

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

Similar topics

2
by: WSeeger | last post by:
When creating a new class, is it encouraged to always include error handling routines within your LET and GET procedures? It's seems that most text books never seem to include much about error...
12
by: Christian Christmann | last post by:
Hi, assert and error handling can be used for similar purposes. When should one use assert instead of try/catch and in which cases the error handling is preferable? I've read somewhere that...
6
by: Squirrel | last post by:
I have a command button on a subform to delete a record. The only statement in the subroutine is: DoCmd.RunCommand acCmdDeleteRecord The subform's recordsource is "select * from tblVisit order...
13
by: Thelma Lubkin | last post by:
I use code extensively; I probably overuse it. But I've been using error trapping very sparingly, and now I've been trapped by that. A form that works for me on the system I'm using, apparently...
21
by: Anthony England | last post by:
Everyone knows that global variables get re-set in an mdb when an un-handled error is encountered, but it seems that this also happens when the variable is defined as private at form-level. So...
3
by: Stefan Johansson | last post by:
Hi all I'am moving from Visual Foxpro and have a question regarding "best practice" error handling in vb .net. In VFP I have always used a "central" error handling object in order to have a...
4
by: Al Williams | last post by:
Hi, I have error handling in place throughout my application. I also start the application wrapped in error handling code to catch any unexpected exceptions (i.e. exceptions that occur where I...
10
by: Anthony England | last post by:
(sorry for the likely repost, but it is still not showing on my news server and after that much typing, I don't want to lose it) I am considering general error handling routines and have...
0
by: Lysander | last post by:
Thought I would give something back with a few articles. This article is a bit of code to add error handling. When I have time, I want to write articles on multilingual databases, and Access...
9
by: MrDeej | last post by:
Hello guys! We have an SQL server which sometimes makes timeouts and connection errors. And we have an function witch writes and updates data in 2 tables on this server. When the SQL server error...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
0
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...

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.