Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
Anonymous
Not applicable

NullReferenceException

A friend and I are working with some Visual C# code and we keep getting the message "System.NullReferenceException: Object reference not set to an instance of an object." How do we fix it? The code is attached.

[Activity(Label = "@string/app_name", Theme = "@style/AppTheme", MainLauncher = true)]
    public class MainActivity : AppCompatActivity
    {
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.homeScreen);
            Button findAirport = FindViewById<Button>(Resource.Id.findAirport);
            Button findPrevious = FindViewById<Button>(Resource.Id.findPrevious);
            Button goHome = FindViewById<Button>(Resource.Id.homeButton);
            findAirport.Click+= (button, e) =>
            SetContentView(Resource.Layout.findNew);
            findPrevious.Click += (button, e) =>
            SetContentView(Resource.Layout.loadPrevious);
            goHome.Click += (button, e) =>
            SetContentView(Resource.Layout.homeScreen);
0 REPLIES 0

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors