Quantcast
Channel: MVPXML Work Item Rss Feed
Viewing all articles
Browse latest Browse all 27

Commented Issue: File included with XInclude is locked after reading [26169]

$
0
0
After reading included XML files with XIncludeReader, the included XML file is locked on filesystem level.

This can be fixed by modifing XIncludeReader.CreateAcquiredInfoset(Uri includeLocation) to:

/// <summary>
/// Creates acquired infoset.
/// </summary>
private string CreateAcquiredInfoset(Uri includeLocation)
{
if (_cache == null)
_cache = new Dictionary<string, WeakReference>();
WeakReference wr;
if (_cache.TryGetValue(includeLocation.AbsoluteUri, out wr) && wr.IsAlive)
{
return (string)wr.Target;
}
else
{
//Not cached or GCollected
WebResponse wRes;
string content = null;
using (Stream stream = GetResource(includeLocation.AbsoluteUri,
_reader.GetAttribute(_keywords.Accept),
_reader.GetAttribute(_keywords.AcceptLanguage), out wRes))
{
using (XIncludingReader xir = new XIncludingReader(wRes.ResponseUri.AbsoluteUri, stream, _nameTable))
{
xir.WhitespaceHandling = _whiteSpaceHandling;
using (StringWriter sw = new StringWriter())
{
using (XmlTextWriter w = new XmlTextWriter(sw))
{
try
{
while (xir.Read())
w.WriteNode(xir, false);
}
finally
{
if (xir != null)
xir.Close();
if (w != null)
w.Close();
}
content = sw.ToString();
}
}
}
}
if (content != null)
{
lock (_cache)
{
if (!_cache.ContainsKey(includeLocation.AbsoluteUri))
_cache.Add(includeLocation.AbsoluteUri, new WeakReference(content));
}
}
return content;
}
}
Comments: ** Comment from web user: williware **

I am having the same issue. The Filestream returned by my resolver is left open.


Viewing all articles
Browse latest Browse all 27

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>