Click here to Skip to main content
15,888,351 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
public Screen2 MyScreen2{ get; set; }
private void Button_Click(object sender, RoutedEventArgs e)
      {
            this.Visibility = System.Windows.Visibility.Collapsed;

            
                this.MyScreen2.Visibility = System.Windows.Visibility.Visible;
            
        }



i try this, shows an 'System.NullReferenceException' => "Object reference not set to an instance of an object".
Here MyScreen2 shows null,
Give some idea's how to resolve it, thanks in advance
Posted
Updated 14-Oct-15 20:58pm
v3

1 solution

You are trying to use something that is null. This means you either set it to null, or you never initialized it.

I would suggest you to step through the code and find the null object.
You should check your MyScreen2 object.


--Amy
 
Share this answer
 
Comments
MVK_VIJI 15-Oct-15 3:08am    
fine, how can i handle it????????
_Amy 15-Oct-15 3:49am    
Try this:
try
{
this.Visibility = System.Windows.Visibility.Collapsed;
this.MyScreen2.Visibility = System.Windows.Visibility.Visible;
}
catch(Exception ex)
{
//Show your custom message here.
}

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900