FIX: Intermittent Problems with User-Defined Events in COM+ (269820)



The information in this article applies to:

  • Microsoft COM+ 1.0

This article was previously published under Q269820

SYMPTOMS

You can define your own events and use the PostEvent method to post the events to an event sink. However, when too many events are posted in a row, the COM+ application may fail (crash) under stress. You may also notice high CPU usage.

RESOLUTION

To resolve this problem, obtain the latest service pack for Windows 2000. For additional information, click the following article number to view the article in the Microsoft Knowledge Base:

260910 How to Obtain the Latest Windows 2000 Service Pack


STATUS

Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article. This problem was first corrected in Windows 2000 Service Pack 2.

MORE INFORMATION

Steps to Reproduce Behavior

Steps to Create Server

  1. Create a Visual Basic ActiveX DLL project in Microsoft Visual Basic 6.0. Class1 is created by default.
  2. Change the project name to "PrjServer".
  3. From the Project menu, add COM+ Services Type Library.
  4. Add the following code to Class1:
    Option Explicit
    
    Public Sub GenerateEvent(str As String)
    
        On Error GoTo errHandler:
    
        Dim oMtsLocator As New COMSVCSLib.CoMTSLocator
        Dim oEventDispatcher As COMSVCSLib.COMEvents
        Dim varEvent As Variant
        Dim ThisContext As ObjectContext
        Dim ThisContextInfo As ContextInfo
        Dim ActivityId As String
    
        Set ThisContext = GetObjectContext()
        Set ThisContextInfo = ThisContext.ContextInfo
        ActivityId = ThisContextInfo.GetActivityId
        Set oEventDispatcher = oMtsLocator.GetEventDispatcher
    
        varEvent = "<Event><ActivityID>" & ActivityId & _
            "</ActivityID><Description>" & str & "</Description></Event>"
    
        oEventDispatcher.PostEvent varEvent
        oEventDispatcher.PostEvent varEvent
        oEventDispatcher.PostEvent varEvent
        oEventDispatcher.PostEvent varEvent
    
        Exit Sub
    errHandler:
         App.LogEvent CStr(Err.Number) + " " + Err.Description
    End Sub
    					
  5. Change the MTSTransactionMode property of Class1 to 1 - NoTransactions.
  6. From the Project menu, click PrjServer Properties. On the General tab, select the Unattended Execution and Retained In Memory check boxes.
  7. Compile the project. PrjServer.dll is generated.
  8. On the Start menu, point to Programs, point to Administrative Tools, and then click Component Services.
  9. Create a COM+ server application with PrjServer.dll.

Steps to Create Client

  1. Create a Standard EXE project in Visual Basic 6.0. Form1 is created by default.
  2. Add a command button (Command1) to Form1.
  3. Add following code to Form1:
    Option Explicit
    
    Private Sub Command1_Click()
        Dim i As Integer
        Dim obj As Object
        
        Set obj = CreateObject("PrjServer.Class1")
        
        For i = 0 To 50
            Call obj.GenerateEvent("test")
        Next i
        
        Set obj = Nothing
    End Sub
    					
  4. Press the F5 key to run the client. Click the command button several times. Notice that either the application fails (crashes), or the application works as expected, but some COM+ events are lost from the Application Event Log.

Modification Type:MajorLast Reviewed:5/8/2002
Keywords:kbbug kbCOMPlusLCE kbDSupport kbWin2000PreSP2Fix kbWin2000SP2Fix KB269820