Microsoft KB Archive/259463

= PRB: MTS Event Log 4098 &quot;Unexpected Object Reference Count&quot; =

Article ID: 259463

Article Last Modified on 2/1/2001

-

APPLIES TO

 Microsoft Transaction Services 2.0, when used with:  Microsoft Windows NT Server 4.0 Standard Edition

 Microsoft Windows NT Workstation 4.0 Developer Edition 

-



This article was previously published under Q259463



SYMPTOMS
Microsoft Transaction Server (MTS) may log the following informational event:

Unexpected object reference count. The object still had references after the run-time environment released its last reference. Unbind

(Package: PSLk108 OSEP) (ProgId: Project.Class) (CLSID: {EA6CD25E-2B12-11D3-8F30-0001FA328EF7}) (Interface: IUnknown) (IID: {00000000-0000-0000-C000-000000000046}) (Method: 2) (Microsoft Transaction Server Internals Information: File: d:\viper\src\runtime\context\ccontext.cpp, Line: 2807)



CAUSE
This log indicates that an object did not return 0 (zero) from the IUnknown::Release method when the MTS context wrapper was releasing it. This informational message indicates the possibility of a leak.

There are two possible reasons for this log:
 * Someone called AddRef on your component without releasing it. This may have been done without the context wrapper. As a result, an instance is left (hanging around--colloquial) in memory, which most likely contributes to a memory leak for the process. To fix this problem, you must find the offending code and correct it.
 * The component is not returning 0 (zero) from IUnknown. The object is released when it has a reference count of 0. The COM specification does not require this, and some tools (such as PowerBuilder) do not return 0 from the last Release.

In this case, to stop the event log, you must wrap the objects in other components (such as Microsoft Visual Basic components) that return 0 from the Release call. The wrapping components must be installed in MTS, and the wrapped components, which must not be installed in MTS, must reside in the same apartment as the wrapping component.



RESOLUTION
To resolve this problem, track the usage of the component that is named in the error message after ProgID. Make sure that you use SafeRef when the component is handing out references to itself.

<div class="status_section">

STATUS
This behavior is by design.

<div class="moreinformation_section">

Steps to Reproduce Behavior
<ol> In Visual Basic, create an ActiveX dynamic-link library (DLL). Name the project &quot;MyRefcount&quot; and the class &quot;CMyRefcount&quot;.</li> Add a reference to Microsoft Transaction Server Type library.</li>  Add the following code to CMyRefcount: Public Function GetMe As Object Dim context As ObjectContext

Set context = GetObjectContext

Set GetMeToo = Me 'should be SafeRef(Me) context.SetComplete End Function </li> Build MyRefcount. Under the Component tab of the Project Properties dialog box, click Binary compatibility in the Version Compatibility list. Add MyRefcount to a new MTS package.</li> Create a Visual Basic Standard EXE.</li> Add a reference to the MyRefcount project.</li>  Add a button to the form, and paste the following code in the handler: Private Sub Command1_Click Dim c As MyRefcount.CMyRefcount Dim c1 As MyRefcount.CMyRefcount Set c = CreateObject(&quot;MyRefcount.CMyRefcount&quot;) Set c1 = c.GetMe End Sub </li> Compile and run the executable file. The above-mentioned message appears in the event log. This informational message appears only in MTS and not in COM+.</li></ol>

Additional query words: Transaction Server 4098

Keywords: kbprb KB259463

-

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

© Microsoft Corporation. All rights reserved.