問題
最近系統上有時會出現「NHibernate.Exceptions.GenericADOException System.Text.EncoderFallbackException」的錯誤,IIS Reset 後,又正常。
過一陣子,又會出現。到底怎麼回事呢?
錯誤訊息如下,
NHibernate.Exceptions.GenericADOException: could not execute query
[ select scuserm0_.USR_ID as col_0_0_, scuserm0_.USR_NAME as col_1_0_ from SCUSERM scuserm0_ where scuserm0_.USR_ID in (?) ]
Name:Scuserm - Value:RM4303
[SQL: select scuserm0_.USR_ID as col_0_0_, scuserm0_.USR_NAME as col_1_0_ from SCUSERM scuserm0_ where scuserm0_.USR_ID in (?)] —> System.Text.EncoderFallbackException: 無法將索引 105 中的 Unicode 字元 \uD83C 轉譯為指定的字碼頁。
於 System.Text.EncoderExceptionFallbackBuffer.Fallback(Char charUnknown, Int32 index)
於 System.Text.EncoderFallbackBuffer.InternalFallback(Char ch, Char*& chars)
於 System.Text.UTF8Encoding.GetBytes(Char* chars, Int32 charCount, Byte* bytes, Int32 byteCount, EncoderNLS baseEncoder)
於 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.SyncTextWriter.WriteLine(String value)
於 NHibernate.AdoNet.AbstractBatcher.ExecuteReader(IDbCommand cmd)
於 NHibernate.Loader.Loader.GetResultSet(IDbCommand st, Boolean autoDiscoverTypes, Boolean callable, RowSelection selection, ISessionImplementor session)
於 NHibernate.Loader.Loader.DoQuery(ISessionImplementor session, QueryParameters queryParameters, Boolean returnProxies)
於 NHibernate.Loader.Loader.DoQueryAndInitializeNonLazyCollections(ISessionImplementor session, QueryParameters queryParameters, Boolean returnProxies)
於 NHibernate.Loader.Loader.DoList(ISessionImplementor session, QueryParameters queryParameters)
— 內部例外狀況堆疊追蹤的結尾 —
於 NHibernate.Loader.Loader.DoList(ISessionImplementor session, QueryParameters queryParameters)
於 NHibernate.Loader.Loader.ListIgnoreQueryCache(ISessionImplementor session, QueryParameters queryParameters)
於 NHibernate.Hql.Ast.ANTLR.Loader.QueryLoader.List(ISessionImplementor session, QueryParameters queryParameters)
於 NHibernate.Hql.Ast.ANTLR.QueryTranslatorImpl.List(ISessionImplementor session, QueryParameters queryParameters)
於 NHibernate.Engine.Query.HQLQueryPlan.PerformList(QueryParameters queryParameters, ISessionImplementor session, IList results)
於 NHibernate.Impl.SessionImpl.List(String query, QueryParameters queryParameters, IList results)
於 NHibernate.Impl.SessionImpl.List[T](String query, QueryParameters parameters)
於 NHibernate.Impl.QueryImpl.ListT
研究
奇怪,查詢資料,為什麼會有 System.IO.TextWriter.SyncTextWriter.WriteLine 呢?
於是設定不要寫 log4net 的 log ,還是會出現。
後來參考 Periodically - Unable to translate Unicode character X at index Y to specified code page 這篇的方式,將設定 show_sql 設為 false 。最近觀察,就沒有再發生那個錯誤了。
1 | <add key="hibernate.show_sql" value="false" /> |