turquoiseowl / i18n

Smart internationalization for ASP.NET
Other
556 stars 156 forks source link

Getting exception at production server. Cannot write to a closed TextWriter #260

Closed 2R-Sync closed 8 years ago

2R-Sync commented 8 years ago

Hi all. I really like the way you deal with languages. Its easy for my developers to add text on the fly. So we have tried it on a test-site on our production server for a while. And from time to time we get the yellow exception page shown. I have a test program that calls the server 3 times every 5 minutes that did not have this issue, and we narrowed it down to when we changed from default language to our local language (English is default and we do not have any updated english translations). So for English text - the text without [#[ ]#] is returned (we cannot use [[[ because it conflicts with some json calls) The function causing the problem is i18n.Domain.Concrete.POTranslationRepository.ParseTranslationFile(String langtag) +462 The exception dictates its a problem with a TextWriter, but ParseTransactionFile do not write to any files, so i think it might due with some logging!? We have a line with Console.WriteLine("Reading file: {0}", path); I will try to comment this line out together with all Console.writes i can find. If anyone got some insights i would appreciate it - i like the way turquoiseowl handles languages i want this to success.

Best regards

The total exception is here: Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[ObjectDisposedException: Cannot write to a closed TextWriter.] System.IO.StreamWriter.Flush(Boolean flushStream, Boolean flushEncoder) +349 System.IO.StreamWriter.Write(Char[] buffer, Int32 index, Int32 count) +103 System.IO.TextWriter.WriteLine(String value) +300 System.IO.SyncTextWriter.WriteLine(String format, Object arg0) +70 i18n.Domain.Concrete.POTranslationRepository.ParseTranslationFile(String langtag) +462 i18n.Domain.Concrete.POTranslationRepository.GetTranslation(String langtag) +60 i18n.TextLocalizer.LoadMessagesIntoCache(String langtag) +257 i18n.TextLocalizer.LookupText(String langtag, String msgkey) +208 i18n.TextLocalizer.TryGetTextFor(String langtag, String msgkey) +211 i18n.LanguageMatching.MatchLists(LanguageItem[] UserLanguages, IEnumerable1 AppLanguages, String key, Func3 TryGetTextFor, String& o_text, Int32 maxPasses, LanguageTag relatedTo, Boolean palPrioritization) +1001 i18n.TextLocalizer.GetText(String msgid, String msgcomment, LanguageItem[] languages, LanguageTag& o_langtag, Int32 maxPasses) +615 i18n.Helpers.TextLocalizerExtensions.GetText(ITextLocalizer textLocalizer, Boolean allowLookupWithHtmlDecodedMsgId, String msgid, String msgcomment, LanguageItem[] languages, LanguageTag& o_langtag, Int32 maxPasses) +161 i18n.<>cDisplayClass1.b0(String nuggetString, Int32 pos, Nugget nugget, String i_entity) +289 i18n.Helpers.<>cDisplayClass1.b0(Match match) +335 System.Text.RegularExpressions.RegexReplacement.Replace(MatchEvaluator evaluator, Regex regex, String input, Int32 count, Int32 startat) +542 System.Text.RegularExpressions.Regex.Replace(String input, MatchEvaluator evaluator) +60 i18n.Helpers.NuggetParser.ParseString(String entity, Func`5 ProcessNugget) +285 i18n.NuggetLocalizer.ProcessNuggets(String entity, LanguageItem[] languages) +271 i18n.ResponseFilter.Flush() +2343 System.Web.HttpWriter.FilterIntegrated(Boolean finalFiltering, IIS7WorkerRequest wr) +603 System.Web.HttpResponse.FilterOutput() +121 System.Web.CallFilterExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +99

System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +165

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.18449

turquoiseowl commented 8 years ago

Thank you for reporting this. The Console.WriteLine calls shouldn't really be there. Appropriate fix has been pushed to the repo. Hopefully that will fix the problem...

2R-Sync commented 8 years ago

We haven't had an issue since so i guess it is fixed