• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Xml.XmlException类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中System.Xml.XmlException的典型用法代码示例。如果您正苦于以下问题:C# XmlException类的具体用法?C# XmlException怎么用?C# XmlException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



XmlException类属于System.Xml命名空间,在下文中一共展示了XmlException类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: v3

 public int v3()
 {
     Exception inner = new Exception();
     XmlException e = new XmlException("error", inner, 14, 36);
     CompareException(e, "Xml_UserException", inner, 14, 36);
     return TEST_PASS;
 }
开发者ID:johnhhm,项目名称:corefx,代码行数:7,代码来源:XmlException.cs


示例2: XmlValidationError

 public XmlValidationError( XmlException ex )
 {
     LineNumber = ex.LineNumber;
     LinePosition = ex.LinePosition;
     Message = ex.Message;
     Severity = XmlSeverityType.Error;
 }
开发者ID:spate,项目名称:Dredmor-XML-Validator,代码行数:7,代码来源:XmlValidationError.cs


示例3: BuildEventFileInfo

 internal BuildEventFileInfo(XmlException e)
 {
   ErrorUtilities.VerifyThrow(e != null, "Need exception context.");
   this.file = e.SourceUri.Length == 0 ? string.Empty : new Uri(e.SourceUri).LocalPath;
   this.line = e.LineNumber;
   this.column = e.LinePosition;
   this.endLine = 0;
   this.endColumn = 0;
 }
开发者ID:nixgupta,项目名称:SolutionReader,代码行数:9,代码来源:BuildEventFileInfo.cs


示例4: CheckXmlException

        protected void CheckXmlException(string expectedCode, XmlException e, int expectedLine, int expectedPosition)
        {
            string actualCode = expectedCode;
            CError.WriteLine("***Exception");
            CError.WriteLineIgnore(e.ToString());
            CError.Compare(e.LineNumber, expectedLine, "CheckXmlException:LineNumber");
            CError.Compare(e.LinePosition, expectedPosition, "CheckXmlException:LinePosition");

            CError.Compare(actualCode, expectedCode, "ec" + e.Message);
        }
开发者ID:johnhhm,项目名称:corefx,代码行数:10,代码来源:CDataReaderTestCase.cs


示例5: ThrowXmlException

 static public void ThrowXmlException(XmlDictionaryReader reader, XmlException exception)
 {
     string s = exception.Message;
     IXmlLineInfo lineInfo = reader as IXmlLineInfo;
     if (lineInfo != null && lineInfo.HasLineInfo())
     {
         s += " " + SR.Format(SR.XmlLineInfo, lineInfo.LineNumber, lineInfo.LinePosition);
     }
     throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(s));
 }
开发者ID:neris,项目名称:corefx,代码行数:10,代码来源:XmlExceptionHelper.cs


示例6: CreateGuideEntry

        /// <summary>
        /// Creates the guide entry from the given text and relvant attributes
        /// </summary>
        /// <param name="xml"></param>
        /// <param name="hiddenStatus"></param>
        /// <param name="style"></param>
        /// <param name="editing"></param>
        /// <returns></returns>
        static public XmlElement CreateGuideEntry(string text, int hiddenStatus, GuideEntryStyle style, int canRead)
        {

            XmlDocument doc = new XmlDocument();
            if (hiddenStatus > 0 && canRead == 0)
            {
                doc.LoadXml("<GUIDE><BODY>This article has been hidden pending moderation.</BODY></GUIDE>");
            }
            else
            {
                try
                {
                    switch (style)
                    {
                        case GuideEntryStyle.GuideML:
                            text = text.Trim();
                            text = Entities.ReplaceEntitiesWithNumericValues(text);
                            //text = HtmlUtils.ReplaceCRsWithBRs(text);
                            text = HtmlUtils.EscapeNonEscapedAmpersands(text);
                            doc.PreserveWhitespace = true;
                            doc.LoadXml(text);
                            AdjustFootnotes(doc);
                            //doc["GUIDE"]["BODY"].InnerXml = HtmlUtils.ReplaceCRsWithBRs(doc["GUIDE"]["BODY"].InnerXml);
                            break;

                        case GuideEntryStyle.PlainText:
                            doc.LoadXml(StringUtils.PlainTextToGuideML(text));
                            break;

                        case GuideEntryStyle.Html:
                            doc.LoadXml("<GUIDE><BODY><PASSTHROUGH><![CDATA[" + text + "]]></PASSTHROUGH></BODY></GUIDE>");
                            break;

                        default:
                            goto case GuideEntryStyle.GuideML;//null styles are generally guideml...
                        //throw new NotImplementedException("Don't know what type of entry we've got here!");
                    }
                }
                catch (XmlException e)
                {
                    //If something has gone wrong log stuff
                    DnaDiagnostics.Default.WriteExceptionToLog(e);

                    var errorMessage = Regex.Replace(e.Message, "position +[0-9][0-9]* ", "", RegexOptions.IgnoreCase);

                    var xmlException = new XmlException(errorMessage, e);

                    throw new ApiException("GuideML Transform Failed", xmlException);
                }
            }

            return doc.DocumentElement;
        }
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:61,代码来源:GuideEntry.cs


示例7: CompareException

 private void CompareException(XmlException e, string ec, Exception inner, int ln, int lp)
 {
     CError.WriteLine(e);
     CError.Compare((object)e.InnerException, (object)inner, "InnerException");
     CError.Compare(e.LineNumber, ln, "LineNumber");
     CError.Compare(e.LinePosition, lp, "LinePosition");
     string s1 = e.StackTrace;
     Type t = e.GetType();
     Exception e2 = e.GetBaseException();
     int i = e.GetHashCode();
     CError.Compare(!String.IsNullOrEmpty(e.Message), "Message");
     string s3 = e.ToString();
 }
开发者ID:johnhhm,项目名称:corefx,代码行数:13,代码来源:XmlException.cs


示例8: DoScratch

        public void DoScratch()
        {
            try {

              //  int i = Int32.Parse("22r");

                XmlException x = new XmlException("Blah error", null, 25, 100);
                throw x;
            }
            catch (XmlException e) {
                Console.WriteLine("Line Number {0}", e.LineNumber);
                Console.WriteLine("Line Position {0}", e.LinePosition);
                Console.WriteLine("Source URI {0}", e.SourceUri);
                Console.WriteLine("Message {0}", e.Message);
                Console.WriteLine("Stack Trace {0}", e.StackTrace);

            }

            catch (FormatException e) {
                Console.WriteLine("Caught Format Exception");

                Console.WriteLine("Helplink {0}", e.HelpLink);
                Console.WriteLine("Message {0}", e.Message);
                Console.WriteLine("Source {0}", e.Source);
                //Console.WriteLine(" {0}");
                //Console.WriteLine(" {0}");
                //Console.WriteLine(" {0}");
                //Console.WriteLine(" {0}");
                //Console.WriteLine(" {0}");

                if (e.Data != null) {
                    Console.WriteLine("Getting extra details");
                    foreach (DictionaryEntry item in e.Data) {
                        Console.WriteLine("The key is '{0}' and the value is: {1}", item.Key, item.Value);
                    }
                }
            }
            catch (Exception e) {
                Console.WriteLine("Caught Exception");
                if (e.Data != null) {
                    foreach (DictionaryEntry item in e.Data) {
                        Console.WriteLine("The key is '{0}' and the value is: {1}", item.Key, item.Value);
                    }
                }
            }
        }
开发者ID:MichaelRoop,项目名称:NET_TestHarness,代码行数:46,代码来源:Scratch.cs


示例9: BuildXmlErrorMessage

        private static string BuildXmlErrorMessage(string fileName, XmlException exception)
        {
            string msg = Path.GetFileName(fileName) + " is not wel-formed." + Environment.NewLine +
                         "Line " + exception.LineNumber + " at position " + exception.LinePosition + Environment.NewLine +
                         exception.Message;

            var lines = File.ReadAllLines(fileName);
            if (exception.LineNumber >= 0 && exception.LineNumber < lines.Count())
            {
                msg += Environment.NewLine + Environment.NewLine;
                if (exception.LineNumber > 1)
                    msg += (exception.LineNumber - 1) + ":  " + lines[exception.LineNumber - 2] + Environment.NewLine;
                if (exception.LineNumber > 0)
                    msg += (exception.LineNumber) + ":  " + lines[exception.LineNumber - 1] + Environment.NewLine;
                msg += (exception.LineNumber + 1) + ":  " + lines[exception.LineNumber];
            }
            return msg;
        }
开发者ID:LeonCheung,项目名称:subtitleedit,代码行数:18,代码来源:XmlDictionariesTest.cs


示例10: SetUpFixture

		public void SetUpFixture()
		{
			List<string> dialogs = new List<string>();
			dialogs.Add("WelcomeDialog");
			dialogs.Add("ProgressDialog");
			wixDocumentFileName = @"C:\Projects\Test\setup.wxs";
			using (SetupDialogListView control = new SetupDialogListView()) {
				control.AddDialogs(wixDocumentFileName, new ReadOnlyCollection<string>(dialogs));
				
				hasErrorsAtStart = control.HasErrors;
				XmlException xmlEx = new XmlException("Error occurred", null, 10, 5);
				control.AddError(wixDocumentFileName, xmlEx);
				Exception ex = new Exception("Error");
				control.AddError(wixDocumentFileName);
				nodesAdded = control.Items.Count;
				
				SetupDialogListViewItem welcomeDialogListItem = (SetupDialogListViewItem)control.Items[0];
				welcomeDialogText = welcomeDialogListItem.Text;
				welcomeDialogId = welcomeDialogListItem.Id;
				welcomeDialogFileName = welcomeDialogListItem.FileName;

				SetupDialogListViewItem progressDialogListItem = (SetupDialogListViewItem)control.Items[1];
				progressDialogText = progressDialogListItem.Text;
				progressDialogId = progressDialogListItem.Id;
				progressDialogFileName = progressDialogListItem.FileName;
				
				SetupDialogErrorListViewItem xmlErrorDialogListItem = (SetupDialogErrorListViewItem)control.Items[2];
				xmlErrorDialogText = xmlErrorDialogListItem.Text;
				xmlErrorDialogErrorLine = xmlErrorDialogListItem.Line;
				xmlErrorDialogErrorColumn = xmlErrorDialogListItem.Column;
				xmlErrorDialogTextColour = xmlErrorDialogListItem.ForeColor;
				xmlErrorDialogTextBackColour = xmlErrorDialogListItem.BackColor;

				SetupDialogErrorListViewItem errorDialogListItem = (SetupDialogErrorListViewItem)control.Items[3];
				errorDialogText = errorDialogListItem.Text;
				errorDialogErrorLine = errorDialogListItem.Line;
				errorDialogErrorColumn = errorDialogListItem.Column;
				errorDialogTextColour = errorDialogListItem.ForeColor;				
				errorDialogTextBackColour = errorDialogListItem.BackColor;
				
				hasErrors = control.HasErrors;
			}
		}
开发者ID:Bombadil77,项目名称:SharpDevelop,代码行数:43,代码来源:AddDialogsToSetupDialogListTestFixture.cs


示例11: FormatXmlErrorMessageFromExceptionMessage

 /// <summary>
 /// Helper method that parses Xml Exception messages to dna meesages
 /// </summary>
 /// <param name="ex">The Xml Exception</param>
 /// <returns>The dna mundged version</returns>
 private static string FormatXmlErrorMessageFromExceptionMessage(XmlException ex)
 {
     string errorMessage = "";
     string exceptionMessge = ex.Message;
     int comma = exceptionMessge.IndexOf(',');
     int fullstop = exceptionMessge.IndexOf('.');
     if (fullstop < comma)
     {
         errorMessage = exceptionMessge.Substring(0, fullstop);
     }
     else
     {
         errorMessage = exceptionMessge.Substring(0, comma);
         comma = exceptionMessge.IndexOf(',', comma + 1);
         if (fullstop > comma && comma != -1)
         {
             errorMessage += exceptionMessge.Substring(comma, fullstop - comma);
         }
     }
     return errorMessage + " on line " + ex.LineNumber.ToString();
 }
开发者ID:rocketeerbkw,项目名称:DNA,代码行数:26,代码来源:HtmlUtils.cs


示例12: ShowXmlNotWellFormed

        public void ShowXmlNotWellFormed()
        {
            XmlException ex = new XmlException("Message");
            treeViewContainer.ShowXmlIsNotWellFormedMessage(ex);

            Assert.AreEqual(0, treeView.Nodes.Count, "TreeView should be cleared.");
            Assert.AreEqual(ex.Message, treeViewContainer.ErrorMessage);
            Assert.AreEqual(0, splitContainer.Panel2.Controls.IndexOf(errorMessageTextBox), "ErrorMessageTextBox should be on top");
            Assert.AreEqual(ex.Message, errorMessageTextBox.Text);
            Assert.IsTrue(errorMessageTextBox.TabStop);
            Assert.IsFalse(attributesGrid.TabStop);
            Assert.IsFalse(textBox.TabStop);
        }
开发者ID:2594636985,项目名称:SharpDevelop,代码行数:13,代码来源:XmlTreeViewContainerTests.cs


示例13: ReadXml

        private void ReadXml()
        {
            try
            {
                XmlReader xmlReader = XmlReader.Create(_streamReader, InternalDeserializer.XmlReaderSettingsForCliXml);
                Deserializer des = new Deserializer(xmlReader);
                while (!des.Done())
                {
                    string streamName;
                    object obj = des.Deserialize(out streamName);

                    //Decide the stream to which data belongs
                    MinishellStream stream = MinishellStream.Unknown;
                    if (streamName != null)
                    {
                        stream = StringToMinishellStreamConverter.ToMinishellStream(streamName);
                    }
                    if (stream == MinishellStream.Unknown)
                    {
                        stream = _isOutput ? MinishellStream.Output : MinishellStream.Error;
                    }

                    //Null is allowed only in output stream
                    if (stream != MinishellStream.Output && obj == null)
                    {
                        continue;
                    }

                    if (stream == MinishellStream.Error)
                    {
                        if (obj is PSObject)
                        {
                            obj = ErrorRecord.FromPSObjectForRemoting(PSObject.AsPSObject(obj));
                        }
                        else
                        {
                            string errorMessage = null;
                            try
                            {
                                errorMessage = (string)LanguagePrimitives.ConvertTo(obj, typeof(string), CultureInfo.InvariantCulture);
                            }
                            catch (PSInvalidCastException)
                            {
                                continue;
                            }
                            obj = new ErrorRecord(new RemoteException(errorMessage),
                                                "NativeCommandError", ErrorCategory.NotSpecified, errorMessage);
                        }
                    }
                    else if (stream == MinishellStream.Information)
                    {
                        if (obj is PSObject)
                        {
                            obj = InformationRecord.FromPSObjectForRemoting(PSObject.AsPSObject(obj));
                        }
                        else
                        {
                            string messageData = null;
                            try
                            {
                                messageData = (string)LanguagePrimitives.ConvertTo(obj, typeof(string), CultureInfo.InvariantCulture);
                            }
                            catch (PSInvalidCastException)
                            {
                                continue;
                            }

                            obj = new InformationRecord(messageData, null);
                        }
                    }
                    else if (stream == MinishellStream.Debug ||
                             stream == MinishellStream.Verbose ||
                             stream == MinishellStream.Warning)
                    {
                        //Convert to string
                        try
                        {
                            obj = LanguagePrimitives.ConvertTo(obj, typeof(string), CultureInfo.InvariantCulture);
                        }
                        catch (PSInvalidCastException)
                        {
                            continue;
                        }
                    }
                    AddObjectToWriter(obj, stream);
                }
            }
            catch (XmlException originalException)
            {
                string template = NativeCP.CliXmlError;
                string message = string.Format(
                    null,
                    template,
                    _isOutput ? MinishellStream.Output : MinishellStream.Error,
                    _processPath,
                    originalException.Message);
                XmlException newException = new XmlException(
                    message,
                    originalException);

//.........这里部分代码省略.........
开发者ID:40a,项目名称:PowerShell,代码行数:101,代码来源:NativeCommandProcessor.cs


示例14: ShowXmlIsNotWellFormedMessage

 public void ShowXmlIsNotWellFormedMessage(XmlException ex)
 {
     notWellFormedMessageDisplayed = true;
     notWellFormedException = ex;
 }
开发者ID:2594636985,项目名称:SharpDevelop,代码行数:5,代码来源:MockXmlTreeView.cs


示例15: LoadData

		private void LoadData ()
		{
			hasht = new Hashtable ();
#if NET_2_0
			hashtm = new Hashtable ();
#endif
			if (fileName != null) {
				stream = File.OpenRead (fileName);
			}

			try {
				xmlReader = null;
				if (stream != null) {
					xmlReader = new XmlTextReader (stream);
				} else if (reader != null) {
					xmlReader = new XmlTextReader (reader);
				}

				if (xmlReader == null) {
					throw new InvalidOperationException ("ResourceReader is closed.");
				}

				xmlReader.WhitespaceHandling = WhitespaceHandling.None;

				ResXHeader header = new ResXHeader ();
				try {
					while (xmlReader.Read ()) {
						if (xmlReader.NodeType != XmlNodeType.Element)
							continue;

						switch (xmlReader.LocalName) {
						case "resheader":
							ParseHeaderNode (header);
							break;
						case "data":
							ParseDataNode (false);
							break;
#if NET_2_0
						case "metadata":
							ParseDataNode (true);
							break;
#endif
						}
					}
#if NET_2_0
				} catch (XmlException ex) {
					throw new ArgumentException ("Invalid ResX input.", ex);
				} catch (Exception ex) {
					XmlException xex = new XmlException (ex.Message, ex, 
						xmlReader.LineNumber, xmlReader.LinePosition);
					throw new ArgumentException ("Invalid ResX input.", xex);
				}
#else
				} catch (Exception ex) {
					throw new ArgumentException ("Invalid ResX input.", ex);
				}
#endif
				header.Verify ();
			} finally {
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:59,代码来源:ResXResourceReader.cs


示例16: Ds3BadResponseException

 public Ds3BadResponseException(XmlException innerException)
     : base(BuildResponseParseException(innerException), innerException)
 {
 }
开发者ID:rpmoore,项目名称:ds3_net_sdk,代码行数:4,代码来源:Ds3BadResponseException.cs


示例17: NewXmlException

 private XmlException NewXmlException(string resourceString, Exception innerException, params object[] args)
 {
     string message = StringUtil.Format(resourceString, args);
     XmlException exception = null;
     XmlTextReader reader = this._reader as XmlTextReader;
     if ((reader != null) && reader.HasLineInfo())
     {
         exception = new XmlException(message, innerException, reader.LineNumber, reader.LinePosition);
     }
     if (exception == null)
     {
         exception = new XmlException(message, innerException);
     }
     return exception;
 }
开发者ID:nickchal,项目名称:pash,代码行数:15,代码来源:InternalDeserializer.cs


示例18: ShowXmlIsNotWellFormedMessage

		public void ShowXmlIsNotWellFormedMessage(XmlException ex)
		{
			ShowErrorMessage(ex.Message);
		}
开发者ID:hpsa,项目名称:SharpDevelop,代码行数:4,代码来源:XmlTreeViewContainerControl.cs


示例19: XmlFileValidationErrorList

 /// <summary>
 /// Constructs an instance based on a <see cref="XmlException"/> that occurred.
 /// </summary>
 /// <param name="filePath"></param>
 /// <param name="ex"></param>
 public XmlFileValidationErrorList( string filePath, XmlException ex )
 {
     Path = filePath;
     Errors = new List<XmlValidationError> { new XmlValidationError( ex ) };
     XmlExceptionOccurred = true;
 }
开发者ID:spate,项目名称:Dredmor-XML-Validator,代码行数:11,代码来源:XmlValidationError.cs


示例20: BuildFileLoadException

 public BuildFileLoadException(string message, XmlException error)
     : this(message, error.LineNumber, error.LinePosition, error)
 {
 }
开发者ID:BackupTheBerlios,项目名称:nantgui,代码行数:4,代码来源:BuildFileLoadException.cs



注:本文中的System.Xml.XmlException类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Xml.XmlNameTable类代码示例发布时间:2022-05-26
下一篇:
C# Xml.XmlElement类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap