示例#1
0
        // <summary>
        // Event handler for the Compiler Errors
        // </summary>
        // <param name="sender"></param>
        // <param name="e"></param>
        private void OnCompilerError(Object sender, MarkupErrorEventArgs e)
        {
            _nErrors++;

            //
            // Since Output from LogError() cannot be recognized by VS TaskList, so
            // we replaced it with LogErrorFromText( ) and pass all the required information
            // such as filename, line, offset, etc.
            //
            string strErrorCode;

            // Generate error message by going through the whole exception chain, including
            // its inner exceptions.
            string message = TaskHelper.GetWholeExceptionMessage(e.Exception);
            string errorText;

            strErrorCode = _taskLogger.ExtractMessageCode(message, out errorText);

            if (String.IsNullOrEmpty(strErrorCode))
            {
                // If the exception is a Xml exception, show a pre-asigned error id for it.
                if (IsXmlException(e.Exception))
                {
                    message      = SR.Get(SRID.InvalidXml, message);
                    strErrorCode = _taskLogger.ExtractMessageCode(message, out errorText);
                }
                else
                {
                    strErrorCode = _unknownErrorID;
                    errorText    = SR.Get(SRID.UnknownBuildError, errorText);
                }
            }

            _taskLogger.LogError(null, strErrorCode, null, e.FileName, e.LineNumber, e.LinePosition, 0, 0, errorText);
        }
        internal void OnError(Exception e)
        {
            if (Error != null)
            {
                XamlParseException xe = e as XamlParseException;
                int lineNum = xe != null ? xe.LineNumber : 0;
                int linePos = xe != null ? xe.LinePosition : 0;
                string filename = SourceFileInfo.OriginalFilePath;

                MarkupErrorEventArgs eea = new MarkupErrorEventArgs(e, lineNum, linePos, filename);
                Error(this, eea);
            }
        }
        // <summary>
        // Event hanlder for the Compiler Errors
        // </summary>
        // <param name="sender"></param>sd brancx
        // <param name="e"></param>
        private void OnCompilerError(Object sender, MarkupErrorEventArgs e)
        {
            _nErrors++;

            //
            // Since Output from LogError() cannot be recognized by VS TaskList, so
            // we replaced it with LogErrorFromText( ) and pass all the required information
            // such as filename, line, offset, etc.
            //
            string strErrorCode;

            // Generate error message by going through the whole exception chain, including
            // its inner exceptions.
            string message = TaskHelper.GetWholeExceptionMessage(e.Exception);
            string errorText;

            strErrorCode = _taskLogger.ExtractMessageCode(message, out errorText);

            if (String.IsNullOrEmpty(strErrorCode))
            {
                // If the exception is a Xml exception, show a pre-asigned error id for it.
                if (IsXmlException(e.Exception))
                {
                    message = SR.Get(SRID.InvalidXml, message);
                    strErrorCode = _taskLogger.ExtractMessageCode(message, out errorText);
                }
                else
                {
                    strErrorCode = _unknownErrorID;
                    errorText = SR.Get(SRID.UnknownBuildError, errorText);
                }
            }

            _taskLogger.LogError(null, strErrorCode, null, e.FileName, e.LineNumber, e.LinePosition, 0, 0, errorText);
        }