Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6584963
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:36:11+00:00 2026-05-25T16:36:11+00:00

I have a WPF application which contains 4 tabs. Tab1 is the first tab

  • 0

I have a WPF application which contains 4 tabs. Tab1 is the first tab loaded with the application. I have a Tab1Load method (the name of the tab) which looks like:

private void Tab1Load(object sender, RoutedEventArgs e)
    {
        myConfig.LoadConfigurationData();
        XiphosDB.DataContext = Xiphos.XiphosDbNames;
    }

myConfig was declared at the top of the Window1.xaml.cs file

LoadConfigData myConfig = new LoadConfigData();

LoadConfigData looks like:

public void LoadConfigurationData()
    {
        LoadGen2Data();
        LoadXiphosData();
        LoadTestConsumerData();
    }

The first method call, LoadGen2Data, runs all the way to the end at which point it sets a value to static object. The call is:

var count = 0;
        foreach (var name in Gen2.allFiNames)
        {
            Gen2.ApiKeys.Add(name, APIKeys[count]);
            Gen2.ConnectStrings.Add(name, connectStrings[count]);
            Gen2.LongNames.Add(name, LongNames[count]);
            count++;
        }

The Gen2 declaration is:

 public class Gen2
{
    public static List<string> allFiNames { get; set; }

    public static Dictionary<string, string> LongNames { get; set; }
    public static Dictionary<string, string> ApiKeys { get; set; }
    public static Dictionary<string, string> ConnectStrings { get; set; }
}

Right after Gen2.ApiKeys.Add is called, the application skips out of the method it is in (LoadGen2Data) without calling the rest of the Add statements and then exits out of the LoadConfigurationData method without calling the remaining two methods (LoadXiphosData and LoadTestConsumerData).

Stepping into the top of the foreach loop I have verified that the “name” value is populated and APIKeys[count] provides a legitimate value (a GUID).

I do not receive any errors. No other debug points are caught and I can move around the application GUI with no problems (and no data).

Any idea what the problem is?

Thanks,

Jason

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T16:36:11+00:00Added an answer on May 25, 2026 at 4:36 pm

    You are hitting a NullReferenceException in:

    public static Dictionary<string, string> LongNames { get; set; }
    

    because the auto-generated backing property is null. This also happens for the other Dictionary variables and the List variable.

    You can fix it like this:

    private static Dictionary<string, string> longNames = new Dictionary<string, string>();
    
    public static Dictionary<string, string> LongNames { get { return longNames; } set { longNames = value; } }
    

    You may even skip the setter in this case.

    public class Gen2
    {
        private static List<string> allFiNames = new List<string> allFiNames();
        public static List<string> AllFiNames { get { return allFiNames; } }
    
        private static Dictionary<string, string> longNames = new Dictionary<string, string>();
        public static Dictionary<string, string> LongNames { get { return longNames; } }
    
        private static Dictionary<string, string> apiKeys = new Dictionary<string, string>();
        public static Dictionary<string, string> ApiKeys { get { return apiKeys; } }
    
        private static Dictionary<string, string> connectStrings = Dictionary<string, string>();
        public static Dictionary<string, string> ConnectStrings { get { return connectStrings; } }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using a WPF c# application. I have a user control which contains
I have a WPF application which presents a list of items. I would like
I have a resource dictionary in my WPF application which contains the style information
I have a wpf application. In the window i have a TextBlock which contains
Please help! Background info I have a WPF application which accesses a SQL Server
I have a simple WPF application which I am trying to start. I am
I have an XBAP WPF application which displays various pages inside of a Frame.
I have a very simple WPF application in which I am using data binding
In my WPF application I have a Canvas in which I do some drawing.
I am developing an application in C# WPF which will have Client-Server architecture (Client

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.