I upgraded a project I did in Visual Studio 2008 to VS 2010 an开发者_JS百科d now the following line won't compile
using (TextWriter textWriter = new StreamWriter(_viewContext.HttpContext.Response.OutputStream))
{
textWriter.Write(_tag.ToString(TagRenderMode.EndTag));
}
The error message I'm getting is:
OutputStream is not available when a custom TextWriter is used.
Can anyone fill me in on what I need to do? Thanks
Edit: the target framework is .Net 3.5
If you have the option of changing the code, try this instead:
using (StreamWriter sw = new StreamWriter(_viewContext.HttpContext.Response.OutputStream))
{
using (TextWriter textWriter = TextWriter.Synchronized(sw))
{
textWriter.Write(_tag.ToString(TagRenderMode.EndTag));
}
}
精彩评论