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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T06:53:45+00:00 2026-06-07T06:53:45+00:00

I have a working database application using WPF and SQL Server 2008 R2, which

  • 0

I have a working database application using WPF and SQL Server 2008 R2, which for two years has been getting its SQL Server connection string from the App.Config file. A few days ago on one dev machine, it started ignoring the App.Config file’s connectionString, and is now using a string from somewhere else (looks like either settings.settings, or the DBML file).

Why might this be happening, and how can I get it to stop doing that?

The app.config starts out like this:

<configuration>
  <configSections>
    <section name="log4net" type="System.Configuration.IgnoreSectionHandler"/>
  </configSections>
  <connectionStrings>
    <add name="DronzApp.Properties.Settings.DronzAppConnectionString"
     connectionString="Server=dronz.db.123.dronzdbserver.com;Database=dronzdb;User ID=dronz;Password=secretsauce;"
     providerName="System.Data.SqlClient" />
 </connectionStrings>

Edit: Thanks for the suggestions from both of you for more info and where to look. I don’t know where a WPF App gets the information that it ought to look in App.Config, or anyplace else, but until I learn that, here are some more pieces:

One of the first things my program does is test the database (which now fails). Right before it does that, it calls the auto-generated function InitializeComponent(), whose auto-generated code is:

        /// <summary>
    /// InitializeComponent
    /// </summary>
    [System.Diagnostics.DebuggerNonUserCodeAttribute()]
    public void InitializeComponent() {
        if (_contentLoaded) {
            return;
        }
        _contentLoaded = true;
        System.Uri resourceLocater = new System.Uri("/DronzApp;component/ui/startwindow.xaml", System.UriKind.Relative);

        #line 1 "..\..\..\UI\StartWindow.xaml"
        System.Windows.Application.LoadComponent(this, resourceLocater);

        #line default
        #line hidden
    }

My start window constructor calls InitializeComponent(); and then tests the database with the line:

int hmm = App.db.Dronz_FooTable.Count();

where App.db is a data context defined in the app.xaml.cs file as:

public static DronzDataDataContext db = new DronzDataDataContext();

where DronzDataDataContext is defined in auto-generated code by LINQ-to-SQL such as:

public partial class DronzDataDataContext : System.Data.Linq.DataContext
…

    public DronzDataDataContext() : 
            base(global::DronzApp.Properties.Settings.Default.DronzConnectionString, mappingSource)
    {
        OnCreated();
    }

Which used to heed the app.config file, and now doesn’t. When I catch the DB exception (which is about a DB version problem because it is trying to use the wrong SQL server) and look at the connection string, it is asking the wrong SQL Server for a file instead of the correct connection string. The connection string it is using seems to match either the DBML file that Linq-to=SQL created when the database schema was imported, or a string in settings.settings (which is a file I don’t really understand where it came from or what I’m supposed to do or not do with it).

  • 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-06-07T06:53:46+00:00Added an answer on June 7, 2026 at 6:53 am

    Ok, I seem to have found and fixed the problem, but I don’t know what caused it, exactly.

    What references the Config file is actually in the .proj file, and somehow it changed to add a reference to app.config at the project root instead of in an App subfolder. From reading other discussion of app.config, I think VS2010 did this automatically perhaps when I was looking at the Project settings in the GUI. Deleting that line of XML manually from the .proj file allowed it to find and use the previous version which points to where the app.config file actually is. Since I didn’t have an app.config file in the project root where the new first line was edited to say it was in the .proj file, it seems to have fallen to looking at settings.settings, where it found the connectionString value where the file was when I imported the database file using Linq to SQL.

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

Sidebar

Related Questions

I have a simple WPF application I'm working on, which performs a SQL query
I'm developing a WPF application using Entity Framework 4 and SQL Server CE database
I have a database working in my local sql server 2005 express edition. I
I'm creating a basic database application in WPF, and I have started using the
I have been developing a Java application using J2EE and a Derby database. My
I have a WPF application using MVVM that utilises TreeViewItemViewModels to simplify working with
I'm working on a web application project using ASP.NET MVC3 and database in SQL
I working on Ruby on Rails application using a PostgreSQL database. I have heard
I have been working an application using PHP & MySql on Codeigniter framework. It
hi i am working on a django python application using sqlite3 database. I have

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.