If this is the wrong newsgroup, appologies, and if you could tell me the
correct group to re-post to
I have a class that loads an xml file, and then navigates to to get a
description based on an id number. When I use this class on my asp.net
project ( not using the vs.net debugger ) the xml file is locked and is not
released until I restart the web service. I am sure that I have missed a
step in regards to releasing the xml file when I am finished.
If anybody could point out my mistake, would be great.
Thanks in advance.
Darren.
This is my class
public class GetError
{
int _Code;
string _Desc;
string _FileName;
XmlTextReader reader;
XmlDataDocument xml_data;
/// <summary>
///
/// </summary>
/// <param name="filename">The file to open, and the xml element
name</param>
public GetError(string filename)
{
_FileName = filename;
reader = new
XmlTextReader(System.Web.HttpContext.Current.Serve r.MapPath("/WebAssist/Constants/"
+ _FileName + ".xml"));
xml_data = new XmlDataDocument();
xml_data.Load(reader);
}
/// <summary>
/// The error code that was looked up
/// </summary>
public int Code
{
get { return _Code; }
set
{
_Code = value;
GetErrorDesc();
}
}
/// <summary>
/// The actual error description
/// </summary>
public string Description
{
get { return _Desc; }
}
/// <summary>
/// ToString representation. Code + Description
/// </summary>
/// <returns></returns>
public override string ToString()
{
return _Code.ToString(CultureInfo.CurrentCulture) + " - " + _Desc;
}
/// <summary>
/// based on the code supplied, get the description
/// </summary>
void GetErrorDesc()
{
_Desc = string.Empty;
XPathNavigator nav;
nav = xml_data.CreateNavigator();
XPathExpression expr;
expr = nav.Compile("descendant::" + _FileName + "[id=" +
_Code.ToString(CultureInfo.CurrentCulture) + "]");
XPathNodeIterator itr;
itr = nav.Select(expr);
itr.MoveNext();
XPathNavigator nav2 = itr.Current.Clone();
nav2.MoveToFirstChild();
nav2.MoveToNext();
_Desc = nav2.Value;
}
}