From 9480b69754cb7f8531d3d1becffb517394d1e68f Mon Sep 17 00:00:00 2001 From: Deathmax Date: Sun, 15 Jan 2012 11:09:48 +0800 Subject: [PATCH] Catch objectdisposedexception when writing to log file --- TShockAPI/Log.cs | 18 ++++++++++++++---- TShockAPI/Properties/AssemblyInfo.cs | 4 ++-- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/TShockAPI/Log.cs b/TShockAPI/Log.cs index 4bbd05ac..77e8ff86 100644 --- a/TShockAPI/Log.cs +++ b/TShockAPI/Log.cs @@ -160,10 +160,20 @@ namespace TShockAPI caller = meth.DeclaringType.Name; } - _logWriter.WriteLine(string.Format("{0} - {1}: {2}: {3}", - DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture), - caller, level.ToString().ToUpper(), message)); - _logWriter.Flush(); + try + { + _logWriter.WriteLine(string.Format("{0} - {1}: {2}: {3}", + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture), + caller, level.ToString().ToUpper(), message)); + _logWriter.Flush(); + } + catch (ObjectDisposedException) + { + Console.WriteLine("Unable to write to log as log has been disposed."); + Console.WriteLine("{0} - {1}: {2}: {3}", + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture), + caller, level.ToString().ToUpper(), message); + } } } } \ No newline at end of file diff --git a/TShockAPI/Properties/AssemblyInfo.cs b/TShockAPI/Properties/AssemblyInfo.cs index a8d53f8f..be5aae10 100644 --- a/TShockAPI/Properties/AssemblyInfo.cs +++ b/TShockAPI/Properties/AssemblyInfo.cs @@ -48,5 +48,5 @@ using System.Runtime.InteropServices; // Build Number // MMdd of the build -[assembly: AssemblyVersion("3.4.5.0114")] -[assembly: AssemblyFileVersion("3.4.5.0114")] +[assembly: AssemblyVersion("3.4.5.0115")] +[assembly: AssemblyFileVersion("3.4.5.0115")]