程序在IDE中调试没有问题,但是编译成.exe之后就会出现“运行时错误‘-2147417848(80010108)’Automation错误”,很不解,我想大概各位也都遇到过,有什么办法可以解决吗,问题是出在哪儿.

解决方案 »

  1.   

    工程--工程1属性--编译--选择:编译成P-代码,然后编译成exe测试一下。
      

  2.   

    FIX: Run-Time Error When DataObject Passed as Object
    Last reviewed: December 18, 1997
    Article ID: Q171812  
    The information in this article applies to: 
    Microsoft Visual Basic Learning, Professional, and Enterprise Editions for Windows, version 5.0 SYMPTOMS
    When you pass a DataObject as an Object to another procedure, you receive one of the following errors:     Run-time error '-2147417848 (80010108)':
         Method 'GetFormat' of object 'IVBDataObject' failedor -     Run-time error '-2147319765 (8002802b)':
        Automation ErrorRESOLUTION
    This problem is corrected with Microsoft Visual Studio 97 Service Pack 2. You may also work around this issue by obtaining the correct interface to the DataObject that contains the GetFormat method. The example below illustrates this workaround. In this example, the DataObject is passed to a subroutine as an Object and is then set to a variable of type MSFlexGridLib.DataObject:    Private Sub MSFlexGrid1_OLEDragDrop( _
          Data As msflexgridlib.DataObject, Effect As Long, Button As _
          Integer, Shift As Integer, x As Single, y As Single)
          PrintIt Data
       End Sub   Sub PrintIt(d As Object)
           Dim iDataObject As MSFlexGridLib.DataObject
           Set iDataObject = d
           Debug.Print iDataObject.GetFormat(vbCFText)
       End SubThis method allows you to communicate directly with the DataObject interface of the Object that is passed to the PrintIt procedure. STATUS
    Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. This bug has been fixed in Visual Studio 97 Service Pack 2. For more information on the Visual Studio 97 Service Pack 2, please see the following article in the Microsoft Knowledge Base:    ARTICLE-ID: Q170365
       TITLE     : INFO: Visual Studio 97 Service Packs - What, Where, and WhyFor a list of the Visual Basic 5.0 bugs that were fixed in the Visual Studio 97 Service Pack 2, please see the following article in the Microsoft Knowledge Base:    ARTICLE-ID: Q171554
       TITLE     : INFO: Visual Basic 5.0 Fixes in Visual Studio 97
                   Service Pack 2MORE INFORMATION
    This error may occur with ActiveX controls that support OLE drag-and-drop. The error does not occur with intrinsic controls. The following list contains some ActiveX controls that exhibit this problem:    Animation
       FlexGrid
       ListView
       Masked EditBox
       Progress Bar
       Rich TextBox
       Slider
       SSTab
       StatusBar
       TabStrip
       Toolbar
       TreeView
       UpDownSteps to Reproduce BehaviorOpen a new "Standard EXE" project. Click Components on the Project menu. Check "Microsoft FlexGrid Control 5.0." Add a TextBox to Form1. Set the OLEDragMode property to 1-Automatic and the OLEDropMode to 1-Manual. Add a FlexGrid to Form1. Set the OLEDropMode to 1-flexOLEDropManual. Add the following code to Form1:       Private Sub MSFlexGrid1_OLEDragDrop( _
             Data As msflexgridlib.DataObject, Effect As Long, Button As _
             Integer, Shift As Integer, x As Single, y As Single)
             PrintIt Data
          End Sub      Sub PrintIt(d As Object)
             Debug.Print d.GetFormat(vbCFText)
          End Sub      Private Sub Text1_OLEDragDrop(Data As DataObject, Effect As Long, _
             Button As Integer, Shift As Integer, x As Single, y As Single)
             PrintIt Data
          End SubPress the F5 key to run the application. Highlight the text in the TextBox, then drag-and-drop it on top of itself. As expected, "True" is printed to the Immediate window. Highlight the text in the TextBox, then drag-and-drop it on top of the FlexGrid. You receive the following error:       Run-time error '-2147417848 (80010108)':
          Method 'GetFormat' of object 'IVBDataObject' failedKeywords          : vb5all VS97FixlistSP3 VS97FixlistSP2 VB5FixlistSP2
    Version           : 5.0
    Platform          : WINDOWS
    Issue type        : kbbug
    Solution Type     : kbfix kbservicepack
     
    --------------------------------------------------------------------------------
    ================================================================================THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY. 
      

  3.   

    微软的开发工具就是这样的,调试模式和运行模式效果不一样是常有的,特别是用API函数的时候就经常有这种问题,不单是VB这样,就连VC有时候也会这样。这种问题有时候和程序运行速度有关,有时候在某些关键的地方停顿一下可能就解决了,但有时候也不见得能处理掉,可能有些东西要换个思路和用法去实现也不一定,要看具体你操作的是什么东西和过程才能判断的。
      

  4.   


    你的exe和工程文件相同路径测试
      

  5.   

    工程中引用的东西重新注册一下试试。我遇到过 scrrun.dll 要重新注册的问题。
      

  6.   

    我初步检查了下,发现时函数参数传递的问题
    '模板状态时,初始化表格
    'iLen,物品数组长度
    'TemDataClses(),数组
    Public Function DemoInitGdsDataCur(ByVal iLen As Long, ByRef TemDataClses() As PurcGdsCls) As Long '
    这是主窗体的一个函数'这个另一个窗体的按钮事件
    Private Sub cmdInput_Click()
    Dim j As Integer
    Dim TemDataCls As PurcConCls
    Dim TemForm As Form
        If iSelWP = -1 Then
            MsgBox "请选择要导入的信息!", vbInformation, "隆企提示"
            Exit Sub
        End If
        MsgBox "1"
        TemOthPacClses(iSelWP).MyFieldDataCols.Item("Id").vFields = Null
        TemOthPacClses(iSelWP).MyFieldDataCols.Item("Dt").vFields = Null
        Set TemDataCls = TemOthPacClses(iSelWP)
        Set TemForm = curForm’主窗体
        
        TemForm.DemoInitGdsDataCur iTemGpacCurLen, TemGotPacCurClses
      
        TemForm.UpdateData True, TemDataCls, bManCls
            Set TemForm = curForm
        
        MsgBox "4"
        Unload Me
    End Sub我把DemoInitGdsDataCur参数拿掉之后就可以调用了,TemGotPacCurClses是当前窗体的一个数组,是不是参数不能是数组呢?
      

  7.   

    这个错误在我这里屡试屡灵,
    只要在 VBA中引用  scrrun.dll
    运行代码就会出现错误 错误号与楼主的不同
    “自动化 (Automation) 错误 对象库未注册”
    scrrun.dll 要重新注册VB中反而没事。
      

  8.   

    调试的时候一点问题都没有,所以我用Msgbox来找哪里出现了问题,发现时调那个函数的时候出问题了,唉,调试的时候为什么能通过呢
      

  9.   


    我前段时间也遇到一样的问题  调试没问题 编译后运行就报错后来是重新安装系统解决的 代码没问题不知道是不是vb6和 .net之间的问题
      

  10.   

    用depends工具逐个查看你vbp文件中引用的所有组件
      

  11.   

    这个是干什么的,“只要在 VBA中引用 scrrun.dll”
      

  12.   

    打开一个EXCEl 进入代码编辑界面
    引用 scrrun.dll
    运行代码 就报错,必须要把 scrrun.dll 重新注册一次,可能是我的系统原因。
    Sub test()
    Dim d As New Dictionary
    d(1) = 1
    End Sub