Console.Write 大约写 46774339次后就会抛出
"Must complete Convert() operation or call Encoder.Reset() before calling GetBytes() or GetByteCount(). Encoder 'Chinese Simplified (GB2312)' fallback 'System.Text.InternalEncoderBestFitFallback'."
异常
源代码
Console.Write("Current Frame:{0}\tFPS:{1}\tPerformance:{2}\r", Global.Loop, Global.Loop * 1000 / interval, idleFrame);求解答!!

解决方案 »

  1.   

    http://social.msdn.microsoft.com/Forums/zh-TW/233/thread/0eec91d5-ae19-48a0-bfbb-8462ccce6577
      

  2.   

    try
                                {
                                    infos = string.Format("Current Frame:{0}\tFPS:{1}\tPerformance:{2}\r", Global.Loop, Global.Loop * 1000 / interval, idleFrame);
                                }
                                catch (System.Exception e)
                                {
                                    throw;
                                }                            try
                                {
                                    Console.Write(infos);                            }
                                catch (System.Exception e)
                                {
                                    throw;
                                }测试了  原因在于下面
     
      

  3.   

    不知道
    现在这样测试中
    不知道会不会都有问题        [DllImport("Kernel32.dll")]
            static extern int WriteConsole
      

  4.   

    又想到了一个解决办法 在测试中
    毕竟直接用windows函数不怎么爽(虽然类库内部也是这样搞的!!!)
    看了一下.net的源代码,它内部用的一个__ConsoleStream的类,然后用StreamWriter封装上,异常出现在StreamWriter中,我直接用__ConsoleStream就好了
      

  5.   

    这一个白搭,竟然是这个类型 SyncTextWriter 晕死
    说明他走了下面
                    TextWriter writer = null; 
                    Stream s;
                    if (stdout)
                        s = OpenStandardOutput(_DefaultConsoleBufferSize);
                    else 
                        s = OpenStandardError(_DefaultConsoleBufferSize);
     
                    if (s == Stream.Null) { 
    #if _DEBUG
                        if (CheckOutputDebug()) 
                            writer = MakeDebugOutputTextWriter((stdout) ? "Console.Out: " : "Console.Error: ");
                        else
    #endif // _DEBUG
                            writer = TextWriter.Synchronized(StreamWriter.Null); 
                    }
                    else { 
                        int codePage = (int) Win32Native.GetConsoleOutputCP(); 
                        Encoding encoding = Encoding.GetEncoding(codePage);
                        StreamWriter stdxxx = new StreamWriter(s, encoding, _DefaultConsoleBufferSize, false); 
                        stdxxx.HaveWrittenPreamble = true;
                        stdxxx.AutoFlush = true;
                        writer = TextWriter.Synchronized(stdxxx);
                    } 
     暂时这样测试一下 Console.Out.Write(aaa, 0, aaa.Length);
      

  6.   

    Console.Out.Write(aaa, 0, aaa.Length);  应当不行
    因为TextWriter也是这样重载的
      

  7.   

    实践证明
    只能自己用API了
            [DllImport("Kernel32.dll")]
            static extern int WriteConsole(
                IntPtr hConsoleOutput, char[] lpBuffer, int nNumberOfCharsToWrite, out int lpNumberOfCharsWritten, int lpReserved);其余的都会宕!
      

  8.   

    大家估计也没有办法了 我揭帖了
    感谢各位回复
    我现在使用API解决,具体解决办法在这儿 http://www.886s.com/blog/?p=67这是我的blog 欢迎大家来看看