private void Dispose(bool disposing)
        {
            if (disposing)
            {
                _closeRecordHandle     = null;
                _recordSearchInt       = null;
                _recordSearchString    = null;
                _recordSearchFloat     = null;
                _recordSearchWord      = null;
                _recordSearchByte      = null;
                _recordCountFromHandle = null;
                _recordCount           = null;

                _recordSearchInt2    = null;
                _recordSearchString2 = null;
                _recordSearchFloat2  = null;
                _recordSearchWord2   = null;
                _recordSearchByte2   = null;

                _readFieldValueCharacter  = null;
                _readFieldValueString     = null;
                _readFieldValueDoubleWord = null;
                _readFieldValueFloat      = null;
                _readFieldValueDate       = null;
                _readFieldValueLong       = null;
                _readFieldValueWord       = null;
                _readFieldValueByte       = null;

                _readFieldValueCharacter2  = null;
                _readFieldValueString2     = null;
                _readFieldValueDoubleWord2 = null;
                _readFieldValueFloat2      = null;
                _readFieldValueDate2       = null;
                _readFieldValueLong2       = null;
                _readFieldValueWord2       = null;
                _readFieldValueByte2       = null;

                _computeCompareCrc = null;
            }

            if (_carsonLib != IntPtr.Zero)
            {
                if (!Kernel32.FreeLibrary(_carsonLib))
                {
                    Marshal.ThrowExceptionForHR(Marshal.GetHRForLastWin32Error());
                }

                _carsonLib = IntPtr.Zero;
            }
        }
        public CarsonLibDll()
        {
            _carsonLib = Kernel32.LoadLibrary("CarsonLib.DLL");

            if (_carsonLib == IntPtr.Zero)
            {
                Marshal.ThrowExceptionForHR(Marshal.GetLastWin32Error());
            }

            //This has to be done since a null SafeFileHandle cannot be passed to a DLL.  This is a kludge workaround.
            this.DatabaseHandles.Main   = new SafeFileHandle((IntPtr)0, true);
            this.DatabaseHandles.Phrase = new SafeFileHandle((IntPtr)0, true);
            this.DatabaseHandles.Wp     = new SafeFileHandle((IntPtr)0, true);

            _closeRecordHandle     = (CloseRecordHandleDelegate)Load <CloseRecordHandleDelegate>("CloseRecordHandle");
            _recordSearchInt       = (RecordSearchIntDelegate)Load <RecordSearchIntDelegate>("RecordSearch");
            _recordSearchString    = (RecordSearchStringDelegate)Load <RecordSearchStringDelegate>("RecordSearch");
            _recordSearchFloat     = (RecordSearchFloatDelegate)Load <RecordSearchFloatDelegate>("RecordSearch");
            _recordSearchWord      = (RecordSearchWordDelegate)Load <RecordSearchWordDelegate>("RecordSearch");
            _recordSearchByte      = (RecordSearchByteDelegate)Load <RecordSearchByteDelegate>("RecordSearch");
            _recordCountFromHandle = (RecordCountFromHandleDelegate)Load <RecordCountFromHandleDelegate>("RecordCountFromHandle");
            _recordCount           = (RecordCountDelegate)Load <RecordCountDelegate>("RecordCount");

            _recordSearchInt2    = (RecordSearchInt2Delegate)Load <RecordSearchInt2Delegate>("RecordSearch");
            _recordSearchString2 = (RecordSearchString2Delegate)Load <RecordSearchString2Delegate>("RecordSearch");
            _recordSearchFloat2  = (RecordSearchFloat2Delegate)Load <RecordSearchFloat2Delegate>("RecordSearch");
            _recordSearchWord2   = (RecordSearchWord2Delegate)Load <RecordSearchWord2Delegate>("RecordSearch");
            _recordSearchByte2   = (RecordSearchByte2Delegate)Load <RecordSearchByte2Delegate>("RecordSearch");

            _readFieldValueCharacter  = (ReadFieldValueCharacterDelegate)Load <ReadFieldValueCharacterDelegate>("ReadFieldValue");
            _readFieldValueString     = (ReadFieldValueStringDelegate)Load <ReadFieldValueStringDelegate>("ReadFieldValue");
            _readFieldValueDoubleWord = (ReadFieldValueDoubleWordDelegate)Load <ReadFieldValueDoubleWordDelegate>("ReadFieldValue");
            _readFieldValueFloat      = (ReadFieldValueFloatDelegate)Load <ReadFieldValueFloatDelegate>("ReadFieldValue");
            _readFieldValueDate       = (ReadFieldValueDateDelegate)Load <ReadFieldValueDateDelegate>("ReadFieldValue");
            _readFieldValueLong       = (ReadFieldValueLongDelegate)Load <ReadFieldValueLongDelegate>("ReadFieldValue");
            _readFieldValueWord       = (ReadFieldValueWordDelegate)Load <ReadFieldValueWordDelegate>("ReadFieldValue");
            _readFieldValueByte       = (ReadFieldValueByteDelegate)Load <ReadFieldValueByteDelegate>("ReadFieldValue");

            _readFieldValueCharacter2  = (ReadFieldValueCharacter2Delegate)Load <ReadFieldValueCharacter2Delegate>("ReadFieldValue");
            _readFieldValueString2     = (ReadFieldValueString2Delegate)Load <ReadFieldValueString2Delegate>("ReadFieldValue");
            _readFieldValueDoubleWord2 = (ReadFieldValueDoubleWord2Delegate)Load <ReadFieldValueDoubleWord2Delegate>("ReadFieldValue");
            _readFieldValueFloat2      = (ReadFieldValueFloat2Delegate)Load <ReadFieldValueFloat2Delegate>("ReadFieldValue");
            _readFieldValueDate2       = (ReadFieldValueDate2Delegate)Load <ReadFieldValueDate2Delegate>("ReadFieldValue");
            _readFieldValueLong2       = (ReadFieldValueLong2Delegate)Load <ReadFieldValueLong2Delegate>("ReadFieldValue");
            _readFieldValueWord2       = (ReadFieldValueWord2Delegate)Load <ReadFieldValueWord2Delegate>("ReadFieldValue");
            _readFieldValueByte2       = (ReadFieldValueByte2Delegate)Load <ReadFieldValueByte2Delegate>("ReadFieldValue");

            _computeCompareCrc = (ComputeCompareCRCDelegate)Load <ComputeCompareCRCDelegate>("ComputeCompareCRC");
        }