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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T07:42:59+00:00 2026-06-09T07:42:59+00:00

I keep getting a null object reference error when im running one of my

  • 0

I keep getting a null object reference error when im running one of my unit test.

Unit Test:

    [Test]
    public void EnumeratedData_ValidInputType_NoErrorAdded()
    {
        List<String> errorMessageList = new List<string>();
        UserInputEntity myEntity = new UserInputEntity();

        myEntity.DataTypes = new List<string>();
        myEntity.DataTypes.Add("DateTime");
        myEntity.DataTypes.Add("datetime");
        myEntity.DataTypes.Add("decimal");
        myEntity.DataTypes.Add("decIMAL");
        myEntity.DataTypes.Add("DOUble");
        myEntity.DataTypes.Add("double");
        myEntity.DataTypes.Add("FLOat");
        myEntity.DataTypes.Add("float");
        myEntity.DataTypes.Add("INT");
        myEntity.DataTypes.Add("int");

        PathReader reader = new PathReader();
        IOManager manager = new IOManager(reader);
        VerificationManager testObject = new VerificationManager(manager);

        testObject.EnumeratedDataTypes(myEntity, errorMessageList);
        Assert.AreEqual(errorMessageList.Count, 0);
    }

Method Code:

    public void EnumeratedDataTypes(UserInputEntity inputs, List<String> errorMessageList)
    {
        inputs.EnumeratedDataTypes = new int[inputs.DataTypes.Count];
        try
        {
            for (int i = 0; i < inputs.DataTypes.Count; i++)
            {
                inputs.EnumeratedDataTypes[i] = (int)Enum.Parse(typeof(Enumerations.ColumnDataTypes), inputs.DataTypes[i].ToUpper());
            }
        }
        catch (Exception ex)
        {
            errorMessageList.Add(ex.Message);
        }
    }

Enum:

class Enumerations
{
    public enum ColumnDataTypes
    {
        DATETIME = 0,
        DECIMAL = 1,
        DOUBLE = 2,
        FLOAT = 3,
        INT = 4
    }
}

ErrorMessage:

FrazerMann.CsvImporter.Entity.Test.EntityVerificationTests.EnumeratedData_ValidInputType_NoErrorAdded:
System.NullReferenceException : Object reference not set to an instance of an object.

Im assumin im overlooking something stupidly simple but i cant see it. id appreciate it if someone could put me out of my misery.

  • 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-09T07:43:01+00:00Added an answer on June 9, 2026 at 7:43 am

    In your EnumeratedDataTypes method, you first set the length of the inputs.EnumeratedDataTypes property to inputs.ColumnNames.Count, which is equal to 0 since it has not been filled with data yet (it is only the List capacity that has been set to 9).

    Next, when filling this array property with data you loop from 0 to index (including) inputs.DataTypes.Count:

    for (int i = 0; i <= inputs.DataTypes.Count; i++)
    

    I count the size of the input.DataTypes list to 10. Thus, you will try to write data to an empty array.

    I propose the following changes:

    First, initialize the inputs.EnumeratedDataTypes array as follows:

    inputs.EnumeratedDataTypes = new int[inputs.DataTypes.Count];
    

    Second, use < instead of <= in the for loop:

    for (int i = 0; i < inputs.DataTypes.Count; i++)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I keep getting a Null Object Refrence Error, but can't tell why. I have
I keep getting an error saying that @android:style/Widget.Holo.Light.Button.Borderless is not public and so can't
Summary: Keep getting null response despite public data and setting callback to enable cross
I keep getting the following error: Cannot access a disposed object. Object name: 'AdoTransaction'.
I keep getting a null exception at the ; below. The ApiUsername & ApiPassword
Keep getting this error after inserting a subdatasheet into a query and trying to
Keep getting the error Arguments are not sufficiently instantiated for the multiplication by addition
I keep getting this error and have no idea why. I googled and scanned
I keep getting this error on emulator: I copied this from a tutorial and
I keep getting this error Error in readPNG(destfile) : libpng error: PLTE: CRC error

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.