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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T15:35:10+00:00 2026-05-22T15:35:10+00:00

Using Linq to sql and server explorer, I mapped to a loginvalidation stored proc.

  • 0

Using Linq to sql and server explorer, I mapped to a loginvalidation stored proc. So I write the following code:

ClientReportingDataContext db = new ClientReportingDataContext();
var data = db.ADMIN_LoginValidation(login, password);

It throws up an exception on the following line:

public ClientReportingDataContext() : 
        base(global::System.Configuration.ConfigurationManager.ConnectionStrings["FeedsConnectionString"].ConnectionString, mappingSource)

Exception thrown:

Object reference not set to an instance of an object.

I’m calling this function from a unit test class. I cann feedsconnectionstring in web.config.

I put the web.config in the unit tests folder, and also under debug and debug/bin. Not sure what I’m missing.

Thanks in advance for any advise.

  • 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-22T15:35:11+00:00Added an answer on May 22, 2026 at 3:35 pm

    For a unit test,

    ConnectionStrings["FeedsConnectionString"].ConnectionString
    

    won’t be reading from your web.config file; it will be reading from the application configuration file for the test runner. Therefore, unless you’ve put FeedsConnectionString in the application configuration file for your test runner,

    ConnectionStrings["FeedsConnectionString"]
    

    is null and so

    ConnectionStrings["FeedsConnectionString"].ConnectionString
    

    is going to throw a NullReferenceException.

    This is why testing and application configuration files don’t get along well.

    You should consider the following:

    public ClientReportingDataContext(string connectionString) :
        base(connectionString, mappingSource)
    

    Then inject your connection string in your test.

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

Sidebar

Related Questions

I have recursive stored procedure on SQL Server. I'm using Linq-to-SQL generated classes, and
I'm using the following LINQ to SQL query on a SQL Server Compact DB
I need to run a stored procedure on SQL Server, using LINQ, and throw
When using Linq to SQL and stored procedures, the class generated to describe the
I'm using LINQ to SQL to get a search result of a FullTextSearch stored
When using compiled queries in entity framework (or linq-to-sql) in combination with SQL Server,
I am starting a new project using C# and ASP.NET 3.5 with SQL Server
Am creating a table with sql server 2008 and using linq to sql. Am
Using LINQ, how do I insert a null value into a SQL Server 2008
I'm trying to save image into sql-server using linq. I set the field type

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.