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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:57:24+00:00 2026-05-25T02:57:24+00:00

I have a shared class library which is being used by an asp.net web

  • 0

I have a shared class library which is being used by an asp.net web application and a console application.

In the web.config of my web app, I have a sectionGroup within the configSections declared, and then the matching settings.

<configSections>
    <sectionGroup name="StockLocator">
          <section name="AppSettings" type="StockLocator.ConfigSettings.AppConfig, StockLocator"/>
    </sectionGroup>
</configSections>

<StockLocator>
    <AppSettings>
        <Settings...... />
    </AppSettings>
</StockLocator>

Everything works when I am reading these settings in the web application. However, when I add this to the App.config of my console application, it is not able to read these settings. Basically whenever I am trying to read anything from the App.config file I just get an error "Object reference not set to an instance of an object."

Not very helpful.

It seems as though this section is just not being read from the app.config file, which leads me to think that you cannot add the configSections to the app.config file? Or is there another way to debug this to get a better error message?

I am reading from the configSections using the code

<Serializable()> _
Public Class AppConfig
    Inherits ConfigurationSection

    ''' <summary>
    ''' Initialises and gets AppConfig SiteSettings
    ''' </summary>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Shared Function getConfig() As AppConfig
        Return CType(ConfigurationManager.GetSection("StockLocator/AppSettings"), AppConfig)
    End Function

    <ConfigurationProperty("Settings")> _
    Public Property Settings() As SettingsElement
        Get
            Return CType(Me("Settings"), SettingsElement)
        End Get
        Set(ByVal value As SettingsElement)
            Me("Settings") = value
        End Set
    End Property

    Public Class SettingsElement
        Inherits ConfigurationElement

        <ConfigurationProperty("SqlConnName")> _
        Public Property SqlConnName() As String
            Get
                Return CType(Me("SqlConnName"), String)
            End Get
            Set(ByVal value As String)
                Me("SqlConnName") = value
            End Set
        End Property

    End Class

End Class

Stack Trace:

at StockLocator.Model.StockLocatorService.MatchStock(StockLocator_Store store) in C:\projects\StockLocator\StockLocator\Model\StockLocator.vb:line 421

  • 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-25T02:57:25+00:00Added an answer on May 25, 2026 at 2:57 am

    If you have other appSettings in your App.config their relative order matters. The configSections section should come before the appSettings. More on this msdn thread

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

Sidebar

Related Questions

I have some ASP.NET web services which all share a common helper class they
Situation is following. I have shared library, which contains class definition - QueueClass :
I have a class which extends Application in an Android tabHost app. In the
Assuming I have a shared activity class defined in a Library project, which does
I have a Class Library project which houses some shared code between other projects
I have a windows form application that uses a Shared class to house all
I have a static class in a shared project, which I want to extend
I have a library which creates objects (instances of class A) and pass them
I have a silverlight class library (not a top-level application) with several user controls
I'm trying to add unit testing to an ASP.NET MVC application I have built.

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.