BUG: Incorrect Err.Number Returned by MTS Component (258574)



The information in this article applies to:

  • Microsoft Windows NT Server 4.0
  • Microsoft Windows NT Workstation 4.0
  • Microsoft Transaction Server 2.0

This article was previously published under Q258574

SYMPTOMS

A Microsoft Transaction Server (MTS) component has a method, which uses a variant as an argument. If a client component calls the method, with a parameter that is not declared as a variant, when the MTS component returns an error hr value (or performs Err.Raise), the caller receives an E_INVALIDARG error message instead of the error hr value.

RESOLUTION

Here are three ways to work around this behavior:

  • Change the function signature to take the real argument type instead of a variant.

  • Declare the variable as a Variant in the component that makes the call.

  • Use late binding (declare the MTS object As Object).
NOTE: This problem does not occur with COM+.

STATUS

Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.

MORE INFORMATION

Steps to Reproduce Behavior

  1. Create an ActiveX DLL in Microsoft Visual Basic and name the project VarTest. Name the class Tester.
  2. Add the following method to Tester:
    Public Sub SampTest( a as Variant)
    Err.Raise 14
    End Sub
    					
  3. Compile the DLL, set the binary compatibility, and then add the DLL to an MTS package.
  4. Create a new Standard EXE. Form1 is created by default.
  5. Add a reference to VarTest.
  6. Add a command button to the form, and then add this code to the Click event of the command button:
    Private Sub Command1_Click()
    Dim d As VarTest.Tester
    Dim l as Long
    
    On Error Goto Label
    
    Set d = CreateObject("VarTest.Tester")
    
    d.SampTest l
    
    Exit Sub
    Label:
    MsgBox Err.Number
    End Sub
    					
  7. Run the executable. You will see this error message: "-2147024809"

    which is 0x80070057 (E_INVALIDARG)

Modification Type:MajorLast Reviewed:11/17/2003
Keywords:kbBug kberrmsg kbpending KB258574