473,407 Members | 2,306 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

XmlException message disappears.

In a property i do this:
....
catch(XmlException e)
{
throw new XmlException("Error processing configuration file!",e);
}

Then I catch it in another class:
catch(XmlException e)
{
MessageBox.Show(e.Message + e.InnerException.Message);
}

With the debugger I see that "Error processing configuration file!" is not
in Message property but in a private field called "args".
Why?
How can I obtain "Error processing configuration file!" being in e.Message
or how can I retrieve args content?
Apr 18 '07 #1
1 2133
Blue,

I'm not sure why this is happening to you; however, this:

using System.Xml;

class Program
{
static void Main(string[] args)
{
Class1 c1 = new Class1();
c1.DoIt();

Console.WriteLine("Hit enter to exit");
Console.ReadLine();
}
}

public class Class1
{
public void DoIt()
{
try
{
Class2 c2 = new Class2();
c2.OneProperty = 0;
}
catch (XmlException e)
{
Console.WriteLine(e.Message + e.InnerException.Message);
}
}
}

public class Class2
{
private int _oneValue = 0;

public int OneProperty
{
get { return _oneValue; }
set
{
try
{
if (value 1)
_oneValue = 1;
else throw new XmlException("Original message");
}
catch(XmlException e)
{
throw new XmlException("Error processing configuration file!",
e);
}
}
}
}

produces the text:
Error processing configuration file!Original message
Dave
Apr 19 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: George CK | last post by:
Hello, I tried to send an xml string got from XmlTextReader from a web service proxy to a web service. The type of the web method is simply "string" It's fine when the string length was small...
3
by: Todd | last post by:
Our ASP.NET (C#) application accepts form entry and saves inputed data in XML. We are finding that users are sometimes cutting and pasting special characters (from MS Word) into these forms....
1
by: George W. | last post by:
When attempting to validate an XML file, If the file is valid, it validates correctly, and it will catch most ValidationEvents without problem. However, I keep getting the following Exception:...
1
by: edi | last post by:
Hi, I have MS .Net Framework v1.1.4322. I have this XML file: <?xml version="1.0" ?> <!--here there are two spaces at the beginning--> <aaa> <a id="1"> <Dept>Finance</Dept>
1
by: news.microsoft.com | last post by:
I am using the XmlReader to look at some xml data fragments. Many times the xml fragment is not readable by the XmlReader, since it isn't valid. For example, I may be looking at only the text...
0
by: Frederico Guimar?es via DotNetMonster.com | last post by:
Hi, I'm trying to use the Microsoft.Web.Services2.Messaging. ISoapFormatter but I receive this error: System.Xml.XmlException: The root element is missing. at System.Xml.XmlTextReader.Read()...
1
by: mohit | last post by:
Hi, I am making a web application in Web Matrix on .NET framework. I have a Login.aspx File and a Users.xml file.I am reading data from Users.xml file using FileStream.The Code is DataSet ds =...
1
by: Tomas | last post by:
When I try to load my xslt i get an xml exception with the message "Root element is missing". The stylesheet works when I preview it in stylus studio, but apparently not in my application. Any...
3
by: =?Utf-8?B?RWQgS3JhbWVy?= | last post by:
I thought this might be useful for someone... I was doing a little work earlier using an Xmldocument class to create & maintain a minor store of data in Xml format. I'd gotten the whole thing...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.