Пример #1
0
        /// <summary>
        /// Gets extended information about an error.
        /// </summary>
        /// <param name="error">The error code about which to retrieve information.</param>
        /// <param name="errinfo">Information about the specified error code.</param>
        /// <returns>An error code.</returns>
        public int JetGetErrorInfo(
            JET_err error,
            out JET_ERRINFOBASIC errinfo)
        {
            TraceFunctionCall();
            this.CheckSupportsWindows8Features("JetGetErrorInfo");

            NATIVE_ERRINFOBASIC nativeErrinfobasic = new NATIVE_ERRINFOBASIC();

            errinfo = new JET_ERRINFOBASIC();

            nativeErrinfobasic.cbStruct = checked ((uint)Marshal.SizeOf(typeof(NATIVE_ERRINFOBASIC)));
            int nativeErr = (int)error;

            int err = Implementation.NativeMethods.JetGetErrorInfoW(
                ref nativeErr,
                ref nativeErrinfobasic,
                nativeErrinfobasic.cbStruct,
                (uint)JET_ErrorInfo.SpecificErr,
                (uint)ErrorInfoGrbit.None);

            errinfo.SetFromNative(ref nativeErrinfobasic);

            return(err);
        }
Пример #2
0
        public void ConvertErrorInfoToNativeAndBackIsLossless()
        {
            var nativeTemp    = this.managed.GetNativeErrInfo();
            var managedActual = new JET_ERRINFOBASIC();

            managedActual.SetFromNative(ref nativeTemp);

            Assert.IsTrue(managedActual.ContentEquals(this.managed));
            Assert.IsFalse(managedActual.ContentEquals(null));
        }
Пример #3
0
        /// <summary>
        /// Gets extended information about an error.
        /// </summary>
        /// <param name="error">The error code about which to retrieve information.</param>
        /// <param name="errinfo">Information about the specified error code.</param>
        /// <returns>An error code.</returns>
        public int JetGetErrorInfo(
            JET_err error,
            out JET_ERRINFOBASIC errinfo)
        {
            TraceFunctionCall("JetGetErrorInfo");
            this.CheckSupportsWindows8Features("JetGetErrorInfo");

            NATIVE_ERRINFOBASIC nativeErrinfobasic = new NATIVE_ERRINFOBASIC();
            errinfo = new JET_ERRINFOBASIC();

            nativeErrinfobasic.cbStruct = checked((uint)Marshal.SizeOf(typeof(NATIVE_ERRINFOBASIC)));
            int nativeErr = (int)error;

            int err = Implementation.NativeMethods.JetGetErrorInfoW(
                ref nativeErr,
                ref nativeErrinfobasic,
                nativeErrinfobasic.cbStruct,
                (uint)JET_ErrorInfo.SpecificErr,
                (uint)ErrorInfoGrbit.None);
            errinfo.SetFromNative(ref nativeErrinfobasic);

            return err;
        }