ObjectDisposedException in SimpleMailWebEventProvider in Integrated Manage Pipeline modeRSS

3 replies

Last post Jun 21, 2012 12:16 PM by RichardD

  • ObjectDisposedException in SimpleMailWebEventProvider in Integrated Manage Pipeline mode

    Nov 01, 2010 09:30 AM|softwhere|LINK

    I migrated a web site from Windows 2003 to Windows 2008 R2 and started receiving the error below when ASP.Net healthmonitoring tries to send an email.

    I do not get the error in "classic" managed pipeline mode - only "integrated" managed pipeline mode.

    Thanks for your help,

    David

     ---------------------------------

    Log Name:      Application
    Source:        ASP.NET 2.0.50727.0
    Date:          10/29/2010 12:29:44 PM
    Event ID:      1301
    Task Category: Web Event
    Level:         Error
    Keywords:      Classic
    User:          N/A
    Computer:      XXXXXXXXXXXXXX
    Description:
    The following exception was thrown by the web event provider 'EmailProvider' in the application '/Report' (in an application lifetime a maximum of one exception will be logged per provider instance):System.ObjectDisposedException: Safe handle has been closed
       at Microsoft.Win32.Win32Native.GetTokenInformation(SafeTokenHandle TokenHandle, UInt32 TokenInformationClass, SafeLocalAllocHandle TokenInformation, UInt32 TokenInformationLength, UInt32& ReturnLength)
       at System.Security.Principal.WindowsIdentity.GetTokenInformation(SafeTokenHandle tokenHandle, TokenInformationClass tokenInformationClass, UInt32& dwLength)
       at System.Security.Principal.WindowsIdentity.get_User()
       at System.Security.Principal.WindowsIdentity.GetName()
       at System.Security.Principal.WindowsIdentity.get_Name()
       at System.Web.Management.WebRequestInformation.FormatToString(WebEventFormatter formatter)
       at System.Web.Management.WebRequestErrorEvent.FormatToString(WebEventFormatter formatter, Boolean includeAppInfo)
       at System.Web.Management.WebBaseEvent.ToString(Boolean includeAppInfo, Boolean includeCustomEventDetails)
       at System.Web.Management.SimpleMailWebEventProvider.GenerateBody(WebBaseEventCollection events, Int32 begin, DateTime lastFlush, Int32 discardedSinceLastFlush, Int32 eventsInBuffer, Int32 messageSequence, Int32 eventsInNotification, Int32 eventsLostDueToMessageLimit)
       at System.Web.Management.SimpleMailWebEventProvider.SendMessageInternal(WebBaseEventCollection events, Int32 notificationSequence, Int32 begin, DateTime lastFlush, Int32 discardedSinceLastFlush, Int32 eventsInBuffer, Int32 messageSequence, Int32 messagesInNotification, Int32 eventsInNotification, Int32 eventsLostDueToMessageLimit)
       at System.Web.Management.SimpleMailWebEventProvider.SendMessage(WebBaseEventCollection events, WebEventBufferFlushInfo flushInfo, Int32 eventsInNotification, Int32 eventsRemaining, Int32 messagesInNotification, Int32 eventsLostDueToMessageLimit, Int32 messageSequence, Int32 eventsSent, Boolean& fatalError)
       at System.Web.Management.MailWebEventProvider.ProcessEventFlush(WebEventBufferFlushInfo flushInfo)
       at System.Web.Management.WebEventBuffer.Flush(Int32 max, FlushCallReason reason)
    Event Xml:
    <Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
      <System>
        <Provider Name="ASP.NET 2.0.50727.0" />
        <EventID Qualifiers="49152">1301</EventID>
        <Level>2</Level>
        <Task>3</Task>
        <Keywords>0x80000000000000</Keywords>
        <TimeCreated SystemTime="2010-10-29T17:29:44.000000000Z" />
        <EventRecordID>1807</EventRecordID>
        <Channel>Application</Channel>
        <Computer>XXXXXXXXXXXXXX</Computer>
        <Security />
      </System>
      <EventData>
        <Data>EmailProvider</Data>
        <Data>/Report</Data>
        <Data>System.ObjectDisposedException: Safe handle has been closed
       at Microsoft.Win32.Win32Native.GetTokenInformation(SafeTokenHandle TokenHandle, UInt32 TokenInformationClass, SafeLocalAllocHandle TokenInformation, UInt32 TokenInformationLength, UInt32&amp; ReturnLength)
       at System.Security.Principal.WindowsIdentity.GetTokenInformation(SafeTokenHandle tokenHandle, TokenInformationClass tokenInformationClass, UInt32&amp; dwLength)
       at System.Security.Principal.WindowsIdentity.get_User()
       at System.Security.Principal.WindowsIdentity.GetName()
       at System.Security.Principal.WindowsIdentity.get_Name()
       at System.Web.Management.WebRequestInformation.FormatToString(WebEventFormatter formatter)
       at System.Web.Management.WebRequestErrorEvent.FormatToString(WebEventFormatter formatter, Boolean includeAppInfo)
       at System.Web.Management.WebBaseEvent.ToString(Boolean includeAppInfo, Boolean includeCustomEventDetails)
       at System.Web.Management.SimpleMailWebEventProvider.GenerateBody(WebBaseEventCollection events, Int32 begin, DateTime lastFlush, Int32 discardedSinceLastFlush, Int32 eventsInBuffer, Int32 messageSequence, Int32 eventsInNotification, Int32 eventsLostDueToMessageLimit)
       at System.Web.Management.SimpleMailWebEventProvider.SendMessageInternal(WebBaseEventCollection events, Int32 notificationSequence, Int32 begin, DateTime lastFlush, Int32 discardedSinceLastFlush, Int32 eventsInBuffer, Int32 messageSequence, Int32 messagesInNotification, Int32 eventsInNotification, Int32 eventsLostDueToMessageLimit)
       at System.Web.Management.SimpleMailWebEventProvider.SendMessage(WebBaseEventCollection events, WebEventBufferFlushInfo flushInfo, Int32 eventsInNotification, Int32 eventsRemaining, Int32 messagesInNotification, Int32 eventsLostDueToMessageLimit, Int32 messageSequence, Int32 eventsSent, Boolean&amp; fatalError)
       at System.Web.Management.MailWebEventProvider.ProcessEventFlush(WebEventBufferFlushInfo flushInfo)
       at System.Web.Management.WebEventBuffer.Flush(Int32 max, FlushCallReason reason)</Data>
      </EventData>
    </Event> 

     

    IIS7 Windows Server 2008 R2

  • Re: ObjectDisposedException in SimpleMailWebEventProvider in Integrated Manage Pipeline mode

    Nov 26, 2010 09:39 PM|lextm|LINK

    It is very likely that you have to stick to classic pipeline.
    Lex Li
    IIS Consulting Services at https://support.lextudio.com/services/consulting.html
    ---------------------------
    This posting is provided "AS IS" with no warranties, and confers no rights.
  • Re: ObjectDisposedException in SimpleMailWebEventProvider in Integrated Manage Pipeline mode

    Dec 05, 2010 04:30 PM|David Di - MSFT|LINK

    Most likely the reason this is failign is that the user context is not available whgen we start tryign to find the name of the user at the time of the event:

    System.Security.Principal.WindowsIdentity.get_Name

    In Integrated Pipeline mode we may end up calling into this before authentication takes place while in Classic mode we are guaranteed to have made it through the authentication stage before we get into .Net functionality.  This is a breakign change between IIS6 and IIS7 and it appears that thsi is a piece that is affected by that change.  At this time I would recommend that you run this application in Classic mode to ensure that the error does not recur.

     ----------------------------------------------------------------

    Please remember to click "Mark as Answer" on the post that helps you, and to click "Unmark as Answer" if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.

    Regards,

    David Dietz
    Microsoft Online Community Support

  • Re: ObjectDisposedException in SimpleMailWebEventProvider in Integrated Manage Pipeline mode

    Jun 21, 2012 12:16 PM|RichardD|LINK

    Sorry for resurrecting an old thread, but I've just run into this precise problem, and I think I've solved it.

    The problem seems to be that the SimpleMailWebEventProvider is buffering the events before it sends them. By the time the event is sent, the request has ended, and IIS has disposed of the WindowsIdentity representing the authenticated user.

    If you turn off buffering, the event is sent immediately, so the WindowsIdentity is still valid. Just set buffer="false" on the system.web/healthMonitoring/providers/add element.