473,396 Members | 1,683 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,396 software developers and data experts.

"Object reference not set to an instance of an object."

shweta
3
hello
i m c# beginner..
i m learning creating constituent controls
but when i debug
"Object reference not set to an instance of an object."
this type of error occurs,
i dont understand where i did mistake
kindly help me...

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;

namespace ControlLib
{
public enum SelectedOptionEnum
{
Amazing,
Good,
OK,
Bad,
Terrible,
None

}
public partial class UserMenu : UserControl
{
private System.Windows.Forms.RadioButton rbtnAmazing;
private System.Windows.Forms.RadioButton rbtnGood;
private System.Windows.Forms.RadioButton rbtnOK;
private System.Windows.Forms.RadioButton rbtnBad;
private System.Windows.Forms.RadioButton rbtnTerrible;

public SelectedOptionEnum SelectedOption
{
get
{
if (rbtnAmazing.Checked)
return SelectedOptionEnum.Amazing;
else if (rbtnGood.Checked)
return SelectedOptionEnum.Good;
else if (rbtnOK.Checked)
return SelectedOptionEnum.OK;
else if (rbtnBad.Checked)
return SelectedOptionEnum.Bad;
else if (rbtnTerrible.Checked)
return SelectedOptionEnum.Terrible;
else
return SelectedOptionEnum.None;
}
set
{
if (value == SelectedOptionEnum.Amazing)
rbtnAmazing.Checked = true;
else if (value == SelectedOptionEnum.Good)
rbtnGood.Checked = true;
else if (value == SelectedOptionEnum.OK)
rbtnOK.Checked = true;
else if (value == SelectedOptionEnum.Bad)
rbtnBad.Checked = true;
else if (value == SelectedOptionEnum.Terrible)
rbtnTerrible.Checked = true;
else
{
rbtnAmazing.Checked = false;
rbtnGood.Checked = false;
rbtnBad.Checked = false;
rbtnOK.Checked = false;
rbtnTerrible.Checked = false;
}

}
}

private void UserMenu_Load(object sender, EventArgs e)
{

}


}

}
Nov 8 '11 #1
3 3234
GaryTexmo
1,501 Expert 1GB
The exception is usually pretty descriptive, and means you're trying to access a property on an null reference. When you run your program and it throws an exception, it usually breaks on a line. Which line does this happen on?
Nov 8 '11 #2
shweta
3
Actually when i debug it shows :-
"code generation for property "SelectedOption" failed. Error was: 'property accessor 'Selected Option'on object 'UserMenu1'threw the following exception:'Object reference not set to an instance of an object."
Nov 10 '11 #3
shweta
3
Hey i understand,wher did i made mistake..anywyz THANK U SO MUCH for ur help.....:)
Nov 10 '11 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Bob Cannistraci | last post by:
A three-tier user authentication system was running without a problem for almost a year and now is suddenly dysfunctional. We don't know of any changes to any of the servers. It's quite maddening....
1
by: vijay | last post by:
Hi I am working on a web application. I have huge form where in I have filled some part of the form and after two hours again I started filling the rest of the form but I got the following error ...
1
by: Chris Magoun | last post by:
I suddenly received an unexpected error in my project. I have been working on this project for some time without this issue. Nothing has changed in the form that caused the exception. A little...
18
by: Microsoft | last post by:
When I try this in my code I alwas get an errormessage: "Object reference not set to an instance of an object" Dim g As System.Drawing.Graphics g.DrawString("Test", New Font("Arial", 12,...
9
by: MrSpock | last post by:
1. Create a new Windows Application project. 2. Open the project properties and check "Make single instance application". 3. Build. 4. Go to the release folder and run the application. 5. Try to...
1
by: DaveO. | last post by:
Hello, I'm calling a VB.NET web service, also from VB.NET, and I get the error " Object reference not set to an instance of an object" on the following line in Reference.vb, when it tries to...
35
by: Chris | last post by:
Hi, I tried to create a class which must change the propety 'visible' of a <linktag in the masterpage into 'false' when the user is logged. But i get the error: "Object reference not set to an...
0
by: =?Utf-8?B?SkhhbGV5?= | last post by:
Our system is: IIS Server: dual Intel Xeon 2.80 GHz, 4 GB Ram Windows Server 2003 SP2 IIS 6.0 SQL Server: dual Intel Xeon 2.80 GHz, 4 GB Ram (separate server) Windows Server 2003 SP2 SQL...
0
by: Tamer Ibrahim | last post by:
Hi, Sometimes, I got the following error message when I use ajax calendar control on some aspx pages : Object reference not set to an instance of an object. Description: An unhandled exception...
2
by: Monty | last post by:
I'm installing an ASP.Net 2.0 web applications project (WAP) application on a production server (Win 2003). I've installed it on XP test machines before and it runs fine. On my production machine I...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.