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 760665
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T15:44:42+00:00 2026-05-14T15:44:42+00:00

I am using VS2008. I have a project, SystemSoftware project, connect with a database

  • 0

I am using VS2008. I have a project, SystemSoftware project, connect with a database and we are using L2E. I have a RuntimeInfo class which contains some shared information there. It looks like this:

public class RuntimeInfo
    {
        public const int PWD_ExpireDays = 30;

        private static RuntimeInfo thisObj = new RuntimeInfo();

        public static string AndeDBConnStr = ConfigurationManager.ConnectionStrings["AndeDBEntities"].ConnectionString;

        private RuntimeInfo() {

        }

        /// <summary>
        /// 
        /// </summary>
        /// <returns>Return this singleton object</returns>
        public static RuntimeInfo getRuntimeInfo()
        {
            return thisObj;
        }
}

Now I added a helper project, AndeDataViewer, to the solution which creates a simple UI to display data from the database for testing/verification purpose.

I don’t want to create another set of Entity Data Model in the helper project. I just added all related files as a link in the new helper project.

In the AndeDataViewer project, I get the connection string from above RuntimeInfo class which is a class from my SystemSoftware project as a linked file. The code in AndeDataViewer is like this:

public class DbAccess : IDisposable
    {
        private String connStr = String.Empty;
        public DbAccess()
        {          
            connStr = RuntimeInfo.AndeDBConnStr;
        }
}

My SystemSoftware works fine that means the RuntimeInfo class has no problem there. But when I run my AndeDataViewer, the statement inside above constructor,

connStr = RuntimeInfo.AndeDBConnStr;

, throws an exception. The exception is copied here:

System.TypeInitializationException was unhandled
  Message="The type initializer for 'MyCompany.SystemSoftware.SystemInfo.RuntimeInfo' threw an exception."
  Source="AndeDataViewer"
  TypeName="MyCompany.SystemSoftware.SystemInfo.RuntimeInfo"
  StackTrace:
       at AndeDataViewer.DbAccess..ctor() in C:\workspace\SystemSoftware\Other\AndeDataViewer\AndeDataViewer\DbAccess.cs:line 17
       at AndeDataViewer.Window1.rbRawData_Checked(Object sender, RoutedEventArgs e) in C:\workspace\SystemSoftware\Other\AndeDataViewer\AndeDataViewer\Window1.xaml.cs:line 69
       at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
      ....
InnerException: System.NullReferenceException
       Message="Object reference not set to an instance of an object."
       Source="AndeDataViewer"
       StackTrace:
            at MyCompany.SystemSoftware.SystemInfo.RuntimeInfo..cctor() in C:\workspace\SystemSoftware\SystemSoftware\src\systeminfo\RuntimeInfo.cs:line 24
       InnerException: 

I cannot understand this because it looks fine to me but why there is an exception? we cannot access static variable when a class is a linked class? A linked class should be the same as the local class I think. “Linked” here means when I add file I use “Add As Link”.

how can I avoid this exception?

EDIT:

I added the SystemSoftware’s App.config to AndeDataViewer as a link. Then fixed that problem but I don’t like it. How about if I have App.config in there already? I don’t want to manually copy connectionstring there either because “manually” means no good.

for those have multiple projects share one database, this link may be helperful when you have trouble: MetadataException: Unable to load the specified metadata resource

  • 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-14T15:44:42+00:00Added an answer on May 14, 2026 at 3:44 pm

    You’ll see this if your application .config file does not define a connection string name “AndeDBEntities”.

    The line

        public static string AndeDBConnStr = 
           ConfigurationManager.ConnectionStrings["AndeDBEntities"].ConnectionString;
    

    Is accessing the ConnectionString property of an object returned by ConnectionStrings["AndeDBEntities"] which may not exist.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 484k
  • Answers 484k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer .logoteam has a width of 20%. the 20% is derived… May 16, 2026 at 7:21 am
  • Editorial Team
    Editorial Team added an answer You have unescaped ampersands & in your URL. They either… May 16, 2026 at 7:21 am
  • Editorial Team
    Editorial Team added an answer Hi talked to Sitecore support the other day and apparently… May 16, 2026 at 7:21 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.