OutOfMemoryException in Microsoft WSE 3.0 Diagnostics.TraceInputFilter

We are still using Microsoft WSE 3.0 and on test server started to get

 
Event Type:        Error

Event Source:    Microsoft WSE 3.0

WSE054: An error occurred during the operation of the TraceInputFilter: System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.

   at System.String.GetStringForStringBuilder(String value, Int32 startIndex, Int32 length, Int32 capacity)

   at System.Text.StringBuilder.GetThreadSafeString(IntPtr& tid)

   at System.Text.StringBuilder.set_Length(Int32 value)

   at System.Xml.BufferBuilder.Clear()

   at System.Xml.BufferBuilder.set_Length(Int32 value)

   at System.Xml.XmlTextReaderImpl.ParseText()

   at System.Xml.XmlTextReaderImpl.ParseElementContent()

   at System.Xml.XmlTextReaderImpl.Read()

   at System.Xml.XmlLoader.LoadNode(Boolean skipOverWhitespace)

   at System.Xml.XmlLoader.LoadDocSequence(XmlDocument parentDoc)

   at System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean preserveWhitespace)

   at System.Xml.XmlDocument.Load(XmlReader reader)

   at System.Xml.XmlDocument.Load(Stream inStream)

   at Microsoft.Web.Services3.Diagnostics.TraceInputFilter.OpenLoadExistingFile(String path)

   at Microsoft.Web.Services3.Diagnostics.TraceInputFilter.Load(String path)

   at Microsoft.Web.Services3.Diagnostics.TraceInputFilter.TraceMessage(String messageId, Collection`1 traceEntries).


 

After investigation it was found, that the problem related to trace files, that become too big. When they were deleted and new files were created, error gone.

 

IsNullOrDefault generic helper function for nullable types

I've wrote  IsNullOrDefault generic helper function
 
    public  static bool IsNullOrDefault<T>(this Nullable<T> param) where T : struct
    {
        T deflt = default(T);
        if (!param.HasValue)
            return true;
        else if (param.Value.Equals(deflt))
            return true;
        return false;
    }
, but then realized that there is more short implementation on stackoverflow submitted by Josh
public static bool IsNullOrDefault<T>(this Nullable<T> value) where T : struct 
{ 
   
return default(T).Equals( value.GetValueOrDefault() ); 
} 
 
public static bool IsValue<T>(this Nullable<T> value, T valueToCheck) where T : struct 
{ 
   
return valueToCheck.Equals((value ?? valueToCheck)); 
} 

 

Helper methods StartOfMonth and StartOfNextMonth

 There are couple methods recently added to My DateTimeHelper class
    public static DateTime StartOfMonth(this DateTime dateValue)
        {
            return new DateTime(dateValue.Year,dateValue.Month,1,0,0,0);
        }
        public static DateTime StartOfNextMonth(this DateTime dateValue)
        {
            return StartOfMonth(dateValue).AddMonths(1);
        }


 

My version of UnhandledExceptionModule

I've created my own version of UnhandledExceptionModule independantly of codePlex project in 2007,

I've used code from http://support.microsoft.com/kb/911816

with considerations from http://www.eggheadcafe.com/articles/20060305.asp  

and done some refactoring. It also allows to use AppSettings["EventLogSourceName"]
 
The zip file also includes TestUnhandledExceptionWAP test project, that I used to investigate issue
 
I've upload the code as patch here
«June»
SunMonTueWedThuFriSat
303112345
6789101112
13141516171819
20212223242526
27282930123
45678910