Пример #1
0
        public String GetErrorDescription(int LcId)
        {
            String errorDesc;

            errorInfo.GetErrorDescription(Convert.ToUInt32(LcId), out errorDesc);
            return(errorDesc);
        }
        internal BackgroundCopyException(IBackgroundCopyError err)
        {
            const uint lang = 0x1; // LANG_NEUTRAL, SUBLANG_DEFAULT

            err.GetError(out ctx, out code);
            try { err.GetErrorContextDescription(lang, out ctxDesc); }
            catch { ctxDesc = unkErr; }
            try { err.GetErrorDescription(lang, out errDesc); }
            catch { errDesc = unkErr; }
            err.GetProtocol(out protocol);
            err.GetFile(out iVal);
        }
Пример #3
0
        internal BackgroundCopyException(IBackgroundCopyError err)
        {
            const uint lang = 0x1;             // LANG_NEUTRAL, SUBLANG_DEFAULT

            err.GetError(out ctx, out code);
            try { ctxDesc = err.GetErrorContextDescription(lang); }
            catch { ctxDesc = SafeCoTaskMemString.Null; }
            try { errDesc = err.GetErrorDescription(lang); }
            catch { errDesc = SafeCoTaskMemString.Null; }
            try { protocol = err.GetProtocol(); }
            catch { protocol = SafeCoTaskMemString.Null; }
            iVal = err.GetFile();
        }
Пример #4
0
        /// <summary>
        /// Centralizes all chores related to stopping and cancelling a copy job, and getting back
        /// from BITS the errors incurred during the job.
        /// </summary>
        /// <param name="copyJob">reference to the copy job object (not job id)</param>
        /// <param name="errMessage">a cumulative error message passed by reference so
        /// that additions can be made</param>
        private void HandleDownloadErrorCancelJob(
            IBackgroundCopyJob copyJob,
            ref string errMessage)
        {
            string singleError             = "";
            string jobDesc                 = "";
            string jobName                 = "";
            Guid   jobID                   = Guid.Empty;
            IBackgroundCopyError copyError = null;

            try
            {
                //  check if job is null; don't try to clean up null references!
                if (null != copyJob)
                {
                    //  get information about this job for reporting the error
                    copyJob.GetDescription(out jobDesc);
                    copyJob.GetDisplayName(out jobName);
                    copyJob.GetId(out jobID);

                    //  find out what the error was
                    copyJob.GetError(out copyError);

                    // use the culture id specified in RESX to tell COM which culture to return err message in:
                    copyError.GetErrorDescription((uint)CULTURE_ID_FOR_COM, out singleError);

                    //  add error to our "stack" of errors:
                    errMessage += singleError + Environment.NewLine;

                    //  notify BITS that we consider this job a loss, forget about it:
                    copyJob.Cancel();

                    //  remove job from collection
                    RemoveCopyJobEntry(jobID);

                    //  log error, but don't throw here; let dnldmgr take care of error
                    //  NOTE that errMessage is used cumulatively for full track of problem
                    errMessage = ApplicationUpdateManager.TraceWrite("[BITSDownloader]", "RES_EXCEPTION_BITSBackgroundCopyError", jobID, jobName, jobDesc, errMessage);

                    ExceptionManager.Publish(new Exception(errMessage));
                }
            }
            finally
            {
                if (null != copyError)
                {
                    Marshal.ReleaseComObject(copyError);
                    copyError = null;
                }
            }
        }
Пример #5
0
        /// <summary>
        /// Creates an exception with the BITS error reference and a language id.
        /// </summary>
        /// <param name="error">The BITS error reference.</param>
        /// <param name="langID">The language Id.</param>
        internal BitsDownloadErrorException(IBackgroundCopyError error, uint langID)
        {
            IBackgroundCopyFile file;

            error.GetError(out contextForError, out errorCode);

            error.GetErrorContextDescription(langID, out contextDescription);
            error.GetErrorDescription(langID, out errorDescription);
            error.GetFile(out file);
            error.GetProtocol(out protocol);

            file.GetLocalName(out fileLocalName);
            file.GetRemoteName(out fileRemoteName);
        }
Пример #6
0
        private string FormatError(IBackgroundCopyError error)
        {
            string contextDescription;
            string errorDescription;

            error.GetErrorContextDescription(1033, out contextDescription);
            error.GetErrorDescription(1033, out errorDescription);

            /*
             * Additional info we might want to add to the status
             *
             * BG_ERROR_CONTEXT contextForError;
             * int errorCode;
             * IBackgroundCopyFile file;
             * string protocol;
             * string fileLocalName;
             * string fileRemoteName;
             *
             * error.GetError(out contextForError, out errorCode);
             * error.GetFile(out file);
             * error.GetProtocol(out protocol);
             *
             * file.GetLocalName(out fileLocalName);
             * file.GetRemoteName(out fileRemoteName);
             *
             */

            var message = errorDescription;

            if (!string.IsNullOrEmpty(contextDescription))
            {
                message += Environment.NewLine + contextDescription;
            }

            return(message);
        }