BUG: Run-Time Error Message -2147417848 (80010108) When Passing Array of Dictionary Objects

This article was previously published under Q270589
This article has been archived. It is offered "as is" and will no longer be updated.
SYMPTOMS
You have a Visual Basic ActiveX DLL that has a method that takes an array of Scripting Dictionary Objects as an argument. It may work fine when your Visual Basic client is run in the Visual Basic integrated development environment (IDE) by using this method, but when you run it as a compiled application, you get the following run-time error message:
Run-time error '-2147417848 (80010108)':
Method '~' of object '~' failed
This only occurs when you use late binding to call the method.
RESOLUTION
Use early binding to work around the problem.
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

Steps to Create Server

  1. Create an ActiveX DLL project with Visual Basic. Class1 is created by default.
  2. Change the project name to MyServer.
  3. On the Project menu, select References, select Microsoft Scripting Runtime, and then click OK.
  4. Copy the following code into Class1:
    Option ExplicitPublic Function Test(ByVal strName As String, objContentsDic() As Dictionary) As String    Test = strNameEnd Function					
  5. Save and compile the project. MyServer.dll is generated and automatically registered.

Steps to Create Visual Basic Client

  1. Create a Standard EXE project with Visual Basic. Form1 is created by default.
  2. On the Project menu, select References, select Microsoft Scripting Runtime, and then click OK.
  3. Add a Command Button to Form1.
  4. Add the following code to Form1:
    Option ExplicitPrivate Sub Command1_Click()    Dim arrDict(1 To 3) As Dictionary    Dim strReturn As String    Dim obj As Object        Dim x As Integer    For x = 1 To 3        Set arrDict(x) = New Dictionary        arrDict(x).Add "DicElement" & x, x    Next        Set obj = CreateObject("MyServer.Class1")    strReturn = obj.Test("test it", arrDict)    MsgBox strReturnEnd Sub					
  5. Press the F5 key to run the project, and then click the Command Button. You may see a message box displaying the words:
    test it
    or else you see the following error message:
    Run-time error '-2147417848 (80010108)':
    Method 'Test' of object '_Class1' failed
  6. Compile the project into project1.exe. Double-click project1.exe in the Windows explorer to run it. Click the Command Button and note the following error message:
    Run-time error '-2147417848 (80010108)':
    Method '~' of object '~' failed
  7. Return to the Visual Basic IDE for the client application.
  8. On the Project menu, select References, select MyServer.dll, and then click OK.
  9. Change the following code line
        Dim obj As Object						
    to be this code line:
        Dim obj As MyServer.Class1						
    This change ensures that early binding is used.
  10. Compile the project, run it again, and note that it works as expected.
-2147417848 80010108 project1 myserver
Properties

Article ID: 270589 - Last Review: 12/05/2015 21:17:48 - Revision: 1.0

Microsoft Visual Basic 6.0 Professional Edition, Microsoft Visual Basic 6.0 Enterprise Edition

  • kbnosurvey kbarchive kbbug kbpending KB270589
Feedback