This project has moved and is read-only. For the latest updates, please go here.

Tests fail on Windows XP

Apr 20, 2010 at 10:35 PM

I downloaded the latest source ( and opened it with Visual Studio 2010, converting the solution to the new format. When I run the unit tests I get 145 tests fail. Looking at the first one, I notice this code in PersistentDictionary.cs. The code looks suspicious because it is using Windows7Grbits.ColumnCompressed when EsentVersion.SupportsWindows7Features is false. I suspect that the two values are reversed, but I don't know for certain. This is for your information.


        private void CreateDataTable(Session session, JET_DBID dbid)
            JET_TABLEID tableid;
            JET_COLUMNID keyColumnid;
            JET_COLUMNID valueColumnid;

            ColumndefGrbit columndefGrbit = EsentVersion.SupportsWindows7Features
                                       ? ColumndefGrbit.None
                                       : Windows7Grbits.ColumnCompressed;

Apr 20, 2010 at 11:08 PM

Ugh. I had that completely wrong, which is embarrassing. I've fixed this. Thank you for reporting it.

I had only been testing on older versions of Windows when making a new release. I think I need to start doing that more often.

Change Set 47252
Committed By: laurionb
Committed On: Tue Apr 20 2010 at 3:04 PM

PersistentDictionary: bugfix: column compression was done completely wrong (reported by mikequinlan)


Apr 20, 2010 at 11:10 PM

After changing the line above by reversing the results of the conditional, the tests still fail. I have traced one of the tests, TestDelete() in DictionaryComparisonTests.cs to the following sequence of calls.

public void Setup()
            this.expected = new Dictionary<string, string>();
            this.actual = new PersistentDictionary<string, string>(DictionaryLocation);

Which evenentually invokes

private void CreateDataTable(Session session, JET_DBID dbid)
            JET_TABLEID tableid;
            JET_COLUMNID keyColumnid;
            JET_COLUMNID valueColumnid;

            ColumndefGrbit columndefGrbit = EsentVersion.SupportsWindows7Features
                                       ? Windows7Grbits.ColumnCompressed
                                       : ColumndefGrbit.None;

            Api.JetCreateTable(session, dbid, this.config.DataTableName, 128, 100, out tableid);
                new JET_COLUMNDEF { coltyp = this.converters.KeyColtyp, cp = JET_CP.Unicode, grbit = columndefGrbit },
                out keyColumnid);

                new JET_COLUMNDEF { coltyp = this.converters.ValueColtyp, cp = JET_CP.Unicode, grbit = columndefGrbit },
                out valueColumnid);

            string indexKey = String.Format(CultureInfo.InvariantCulture, "+{0}\0\0", this.config.KeyColumnName);
            var indexcreates = new[]
                new JET_INDEXCREATE
                    cbKeyMost = SystemParameters.KeyMost,
                    grbit = CreateIndexGrbit.IndexPrimary,
                    szIndexName = "primary",
                    szKey = indexKey,
                    cbKey = indexKey.Length,
                    pidxUnicode = new JET_UNICODEINDEX
                        lcid = CultureInfo.InvariantCulture.LCID,
                        dwMapFlags = Conversions.LCMapFlagsFromCompareOptions(CompareOptions.None),
            Api.JetCreateIndex2(session, tableid, indexcreates, indexcreates.Length);

In PersistentDictionary.cs. The Api.JetCreateIndex2 call fails with the error JET_errInvalidLanguageID.


Apr 20, 2010 at 11:16 PM

The indexcreates array value is:


-indexcreates	{Microsoft.Isam.Esent.Interop.JET_INDEXCREATE[1]}	Microsoft.Isam.Esent.Interop.JET_INDEXCREATE[]
-	[0]	{Microsoft.Isam.Esent.Interop.JET_INDEXCREATE}	Microsoft.Isam.Esent.Interop.JET_INDEXCREATE
		cbKey	6	int
		cbKeyMost	255	int
		cbVarSegMac	0	int
		cConditionalColumn	0	int
		err	Success	Microsoft.Isam.Esent.Interop.JET_err
		grbit	IndexPrimary	Microsoft.Isam.Esent.Interop.CreateIndexGrbit
-		pidxUnicode	{Microsoft.Isam.Esent.Interop.JET_UNICODEINDEX}	Microsoft.Isam.Esent.Interop.JET_UNICODEINDEX
			dwMapFlags	0	uint
			lcid	127	int
		rgconditionalcolumn	null	Microsoft.Isam.Esent.Interop.JET_CONDITIONALCOLUMN[]
		szIndexName	"primary"	string
		szKey	"+Key\0\0"	string
		ulDensity	0	int
-		Static members		
			Unicode	None	Microsoft.Isam.Esent.Interop.CreateIndexGrbit

(sorry for the formatting)


Apr 20, 2010 at 11:24 PM

The underlying problem is going to be the fact that older versions of Windows don't support the same range of language ids. I believe I broke this when I changed the code from CultureInfo.CurrentCulture to CultureInfo.InvariantCulture.

Can you try changing:

lcid = CultureInfo.InvariantCulture.LCID


lcid = CultureInfo.CurrentCulture.LCID,
Apr 20, 2010 at 11:30 PM

That has fixed the problem. Thanks! And sorry for using such an old OS <grin>. They say that next week I can upgrade to Windows 7.

Apr 20, 2010 at 11:30 PM

Also. I'm checking out test machines for XP, W2K3, Vista etc. and I'm going to run a full test pass on all of them.



Apr 20, 2010 at 11:35 PM

I'm sorry you had problems, but thank you again for reporting them. I'm getting ready for a new release so this is a good reminder that I need to stay on top of the OS compatability tests.