Results 1 to 5 of 5

Thread: Object reference not set to an instance of an object in KeyValuePairComparer<TKey, TV

  1. #1

    Default Object reference not set to an instance of an object in KeyValuePairComparer<TKey, TV

    Run the following test code, it will throw "Object reference not set to an instance of an object" in KeyValuePairComparer<TKey, TValue> class:


            private static void TestByteArray()
            {
                using (IStorageEngine engine = STSdb.FromFile("test.stsdb4"))
                {
                    //part 1
                    var table1 = engine.OpenXTable<string, byte[]>("binary");
                    var b1 = new byte[] { 0x01, 0x02, 0x03, 0x04 };
                    table1["b"] = b1;
                    engine.Commit();
    
    
                    var b2 = table1["b"];
                    Debug.Assert(b2 != null);
    
    
    
    
                    //part 2
                    var table2 = engine.OpenXTable<byte[], string>("guid");
                    var k = Guid.NewGuid().ToByteArray();
                    var v = "value";
                    table2[k] = v;
                    engine.Commit();
    
    
                    var v2 = table2[k];
                    Debug.Assert(v == v2);
                }
            }
    
    If you run part1 or part2 separately, it is fine.

  2. #2

    Default

    Thank you for the report. We will investigate the issue.

  3. #3
    Junior Member
    Join Date
    Jul 2014
    Posts
    4

    Default Same error on GUID keys

    I got the Null Reference error on the Comparer also. In STSdb4.General.Comparers - the public IComparer<TKey> Comparer { get; private set; } value is null so it was apparently not set.

    I am evaluating STSdb4 and feel I can't use it unless you have a work-around for this in the next day or so?

    ed@pingplotter.com

  4. #4

    Default

    The above code example works fine with 4.0.4.

  5. #5
    Junior Member
    Join Date
    Sep 2016
    Posts
    1

    Default

    Object reference not set to an instance of an object. exactly what it says, you are trying to use a null object as if it was a properly referenced object. Most of the time, when you try to assing value into object, and if the value is null, then this kind of exception occur. NullReferenceException indicates that you are trying to access member fields, or function types, on an object reference that points to null. That means the reference to an Object which is not initialized.

    Wells

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
2002 - 2014 STS Soft SC. All Rights reserved.
STSdb, Waterfall Tree and WTree are registered trademarks of STS Soft SC.