Microsoft KB Archive/269820

= FIX: Intermittent Problems with User-Defined Events in COM+ =

Article ID: 269820

Article Last Modified on 5/8/2002

-

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.



Steps to Create Server
 Create a Visual Basic ActiveX DLL project in Microsoft Visual Basic 6.0. Class1 is created by default. Change the project name to &quot;PrjServer&quot;. From the Project menu, add COM+ Services Type Library.  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 = &quot;&quot; & ActivityId & _ &quot;<Description>&quot; & str & &quot;</Description></Event>&quot;

oEventDispatcher.PostEvent varEvent oEventDispatcher.PostEvent varEvent oEventDispatcher.PostEvent varEvent oEventDispatcher.PostEvent varEvent

Exit Sub errHandler: App.LogEvent CStr(Err.Number) + &quot; &quot; + Err.Description End Sub </li> Change the MTSTransactionMode property of Class1 to 1 - NoTransactions.</li> From the Project menu, click PrjServer Properties. On the General tab, select the Unattended Execution and Retained In Memory check boxes.</li> Compile the project. PrjServer.dll is generated.</li> On the Start menu, point to Programs, point to Administrative Tools, and then click Component Services.</li> Create a COM+ server application with PrjServer.dll.</li></ol>

Steps to Create Client
<ol> Create a Standard EXE project in Visual Basic 6.0. Form1 is created by default.</li> Add a command button (Command1) to Form1.</li>  Add following code to Form1: Option Explicit

Private Sub Command1_Click Dim i As Integer Dim obj As Object Set obj = CreateObject(&quot;PrjServer.Class1&quot;) For i = 0 To 50 Call obj.GenerateEvent(&quot;test&quot;) Next i   Set obj = Nothing End Sub </li> 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.</li></ol>

Additional query words: crash

Keywords: kbbug kbfix kbcompluslce kbwin2000presp2fix KB269820

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.