积极答复者
急,关于CONSOLE.WRITE异常问题?

问题
-
应用在使用过程中出现下列错误。
[EXP]12:46:58 563 必须首先完成 Convert() 操作或调用 Encoder.Reset(),然后 才
能调用 GetBytes() 或 GetByteCount()。编码器“简体中文(GB2312)”回退“System.Text.InternalEncoderBestFitFallback”。 在System.Text.DBCSCodePageEncoding.GetBytes(Char* chars, Int32 charCount,Byte* bytes, Int32 byteCount, EncoderNLS encoder)在 System.Text.EncoderNLS.GetBytes(Char* chars, Int32 charCount, Byte*bytes, Int32 byteCount, Boolean flush)在 System.Text.EncoderNLS.GetBytes(Char[] chars, Int32 charIndex,Int32charCount, Byte[] bytes, Int32 byteIndex, Boolean flush)在 System.IO.StreamWriter.Flush(Boolean flushStream, BooleanflushEncoder)在 System.IO.StreamWriter.Write(Char[] buffer, Int32 index, Int32count)在 System.IO.TextWriter.WriteLine(String value)在 System.IO.TextWriter.SyncTextWriter.WriteLine(String value)在 System.Console.WriteLine(String value)在 EngineWCFService.Business.GetTask(Task& task)
我查了下,Console.WriteLine有2G的内存限制,但是我写个测试程序PF使用率只有1.2G左右便不再增加,无法重现。
我想问问:
1.什么情况下出现这种状况,应用服务器为win server2003
2.有没有解决方案?
答案
-
Hi 江中花园,
我发现像你这个的一些类似的帖子,如下显示:1.http://social.msdn.microsoft.com/Forums/zh-TW/233/thread/0eec91d5-ae19-48a0-bfbb-8462ccce6577
2. http://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/924c74ab-7239-4e17-a178-8db158a1d942的确,你的可能并不是2G的限制问题,你如果再遇到类似的问题,你可以联系https://connect.microsoft.com ,感谢你对微软产品的支持,如果有任何不清楚请主动联系我。
orichisonic http://blog.csdn.net/orichisonic If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".
- 已标记为答案 Lie YouModerator 2012年2月21日 2:11
全部回复
-
-
請問您有參考過這個嗎?
ocurred a exception by Console.WriteLineException on StreamWriter.WriteLine() when exporting more than 2GB file
亂馬客blog: http://www.dotblogs.com.tw/rainmaker/
-
异常代码:
Console.WriteLine("["+DateTime.Now.ToString()+"]队列任务条数<" + Program.DicTaskList.Count+">---柜员"+task.OperID+"取缓存任务耗时<"+sw.ElapsedMilliseconds+"ms>");
在 System.Console.WriteLine(String value) 此方法抛出
此异常抛出后,整个控制台停滞,所有的 Console.WriteLine都抛此异常。
重启后应用正常。
您好
有確認相關變數,都有值且能轉型為 string 嗎?
Console.WriteLine("["+DateTime.Now.ToString()+"]队列任务条数<" + Program.DicTaskList.Count.ToString() +">---柜员"+task.OperID.ToString()+"取缓存任务耗时<"+sw.ElapsedMilliseconds.ToString()+"ms>");
歡迎參觀我的Blog.NET菜鳥自救會
-
值是肯定有的,tostring()没太在意。毕竟运行2年了,第一次出现。
但是还有一个地方也抛出了。
12:35:30 715 .1. [ × ] System.ArgumentException: 必须首先完成 Convert() 操作或调用 Encoder.Reset(),然后才能调用 GetBytes() 或 GetByteCount()。编码器“简体中文(GB2312)”回退“System.Text.InternalEncoderBestFitFallback”。
在 System.Text.DBCSCodePageEncoding.GetBytes(Char* chars, Int32 charCount, Byte* bytes, Int32 byteCount, EncoderNLS encoder)
在 System.Text.EncoderNLS.GetBytes(Char* chars, Int32 charCount, Byte* bytes, Int32 byteCount, Boolean flush)
在 System.Text.EncoderNLS.GetBytes(Char[] chars, Int32 charIndex, Int32 charCount, Byte[] bytes, Int32 byteIndex, Boolean flush)
在 System.IO.StreamWriter.Flush(Boolean flushStream, Boolean flushEncoder)
在 System.IO.StreamWriter.Write(Char[] buffer, Int32 index, Int32 count)
在 System.IO.TextWriter.WriteLine(String value)
在 System.IO.TextWriter.SyncTextWriter.WriteLine(String value)
在 System.Console.WriteLine(String value)
在 SunImgCutter.ImageCut.WriteLog(String info)
在 SunImgCutter.ImageCut.Cut(String index)
在 SunImgCutter.Execute.CutTask()也是一样的。现在问题就是无法重现,然后解决方案还没有。
-
Hi 江中花园,
我发现像你这个的一些类似的帖子,如下显示:1.http://social.msdn.microsoft.com/Forums/zh-TW/233/thread/0eec91d5-ae19-48a0-bfbb-8462ccce6577
2. http://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/924c74ab-7239-4e17-a178-8db158a1d942的确,你的可能并不是2G的限制问题,你如果再遇到类似的问题,你可以联系https://connect.microsoft.com ,感谢你对微软产品的支持,如果有任何不清楚请主动联系我。
orichisonic http://blog.csdn.net/orichisonic If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".
- 已标记为答案 Lie YouModerator 2012年2月21日 2:11