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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:39:26+00:00 2026-05-27T05:39:26+00:00

I have written a project by ASP.NET and C# which uses dataset for connecting

  • 0

I have written a project by ASP.NET and C# which uses dataset for connecting to database.
I want to test my code by when I create a unit test for my classes which use dataset I get following error:

Test method Test.CommodityRepositoryTest.GetCommoditiesTest threw exception: 
System.NullReferenceException: Object reference not set to an instance of an object.
at Terminal.Database.TransportCo.TransportCoTableAdapters.ConfigurationTableAdapter.InitConnection() in TransportCoDataSet.Designer.cs: line 12259
at Terminal.Database.TransportCo.TransportCoTableAdapters.ConfigurationTableAdapter.get_Connection() in TransportCoDataSet.Designer.cs: line 12144
at Terminal.Database.TransportCo.TransportCoTableAdapters.ConfigurationTableAdapter.InitAdapter() in TransportCoDataSet.Designer.cs: line 12227
at Terminal.Database.TransportCo.TransportCoTableAdapters.ConfigurationTableAdapter.get_Adapter() in TransportCoDataSet.Designer.cs: line 12133
at Terminal.Database.TransportCo.TransportCoTableAdapters.ConfigurationTableAdapter.GetData() in TransportCoDataSet.Designer.cs: line 12290

I have to mention that I use singleton repository but it does not change anything in the error.

does anyone has any idea?

these are my code and its test:

public List<Commodity> GetCommodities()
    {         
        var commoditySet=new CommodityTableAdapter();
        var commoditys = commoditySet.GetCommdity().ToList();
        if (commoditys.Count() == 0)
            throw new UserInterfaceException("هیچ کالایی در سیستم ثبت نشده است");
        var commoditiesName = new List<Commodity>();
        for (int i = 0; i < commoditys.Count(); i++)
            commoditiesName.Add(ConvertcommodityRowTocommodity(commoditys[i]));
        return commoditiesName;
    }





   [TestMethod()]
    public void GetCommoditiesTest()
    {
        var target = CommodityRepository.GetInstance(); // TODO: Initialize to an appropriate value
        var expected = new List<Commodity> {new Commodity() {HSCode = "323423", ID = 19}}; // TODO: Initialize to an appropriate value
        List<Commodity> actual = target.GetCommodities();
        Assert.AreEqual(expected[0].ID, actual[0].ID);            
        //Assert.Inconclusive("Verify the correctness of this test method.");
    }
  • 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-27T05:39:27+00:00Added an answer on May 27, 2026 at 5:39 am

    Your typing is ambiguous

    var commoditys = commoditySet.GetCommdity().ToList();
    

    use insteand explicit types

    Object commoditys = commoditySet.GetCommdity().ToList();
    

    then you will receive appropriate debugging errors.

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

Sidebar

Related Questions

I have a website (ASP.NET) and some winforms(.Net 2.0) for a project (written in
I have a C# ASP.NET MVC project but my controllers are written in F#.
I have an ASP.NET 3.5 webforms project written in VB that involves a multi-table
I have an ASP.NET (C#) application, written with VS 2008, that uses CodeBehind files
I have written a message board as my first ASP.NET project. It seems to
i have an ASP.NET project written in Delphi.NET with Borland Studio 2006. Well it
I have written a Flex Library project - a .swc file - which is
I have a rather large (freeware) project written with Delphi 2007 which is using
I have an ASP.NET MVC 3 (using Entity Framework 4.2) application that uses transactions
I'm building an ASP.Net MVC website. Rather than have everything in one project, I've

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.