What does “Method '~' of object '~' failed” at runtime mean?

后端 未结 8 1779
耶瑟儿~
耶瑟儿~ 2020-12-01 13:41

I\'m trying to run a legacy VB6 application on my desktop (it doesn\'t have a user interface, being a command-line app), and when I do, I get a message box saying

         


        
相关标签:
8条回答
  • 2020-12-01 14:25

    This message occurs when a Visual Basic 6 application makes a COM interface call which throws an exception (i.e. returns a failure HRESULT). In this case, VB6 jumps to an exception handler (as set by On Error). In the exception handler there is visible an object Err which contains details of the exception.

    If the object implements ISupportErrorInfo, and it does actually support error info, and it did set error info, then Err.Description takes the string that is in the error info set by the object. Otherwise, Err.Description takes the string Method ~ of ~ failed.

    IDK whether other versions of VB do the same thing; or if the message is also set in other scenarios besides the one I have just described.

    0 讨论(0)
  • 2020-12-01 14:25

    Another cause can be when using automation, some minor-version mismatch of Office:

    I have a legacy VB5+Access app (which i'm in the process of rewriting in Delphi and replacing all the automation mess with clean OpenDocument generation) that ran well on some systems and gave the error on others.

    This error would happen when generating an Excel spreadsheet, and seemed harmless (except the annoyance and as it would show a dozen times the risk of user clicking 'Abort' in the middle) as if always clicking 'Ignore' everything worked as expected.

    I eventually found the cause was the way Office 97 was installed:

    The error would show up if the Office 97 setup sequence was:

    • Office 97 SR0 install CD
    • apply SR1 patch
    • apply SR2 patch

    but not if it was installed with:

    • Office 97 SR1 install CD
    • apply SR2 patch

    Doing an uninstall / reinstall with SR1 setup on the affected systems solved the problem.

    0 讨论(0)
  • 2020-12-01 14:30

    That can happen when supporting libraries (dlls or ocxs) are not registered properly or the versions of the installed libraries are different (and incompatible) with the version the app was compiled against originally.

    Make sure all dependent libraries are registered and the proper version.

    You may have to recompile the app to make it work with newer versions of the supporting libraries.

    0 讨论(0)
  • 2020-12-01 14:33

    As per my experience, it is due to Microsoft Access Version.

    My program was made in MS Office 2007 and installed newer version of MS Office. Thats why this error appears.

    0 讨论(0)
  • 2020-12-01 14:34

    I had this Problem for a While.

    I looked for a Answer and This WebPage was Top of Search.

    A Moment Ago.

    I uninstalled Office 2000 Toolbar

    Uninstalled Visual Basic 6 and Removed all But not MSDN

    Reinstalled Visual Basic 6

    But I always Had My Clipboard Logger Program in Visual Basic 6 was Running

    and Found That Was The Error

    Without that Running I don't Get the Error

    Method of "~" Object "~" Failed

    When Starting Visual Basic 6 IDE

    After Running The Clipboard Code VB6 Program with Ctrl F5

    Start With Full Compile

    and Cured of Compile Errors in the Code

    But Still With Problem Loading VB6 IDE

    Until I Put - Option Explicit Through Whole Clipboard Code

    Except One Module That was too Big to Complete Quickly

    But Especially in the Class Module

    That Had some Undeclared Variables

    and Then That Cured It

    That's My Personal Solution and Contribution to This Web Log

    An Additional Update and Edit Here

    After Reading the 3 Threads of This Subject One of Here about the Clipboard https://stackoverflow.com/a/8577499/5226365

    and I spotted the Bug Again Testing Again

    As This Is My Clipboard Code

    and I was Annoyed at VB6 IDE Using the Clipboard at Load Especially When Carrying a Clipboard Into Code

    and I made The Code Intercept the VB6 IDE Load of a Bitmap and Put back what was there Before

    Now I have to Be More Considerate in my Code and Wait for the Splash Screen to Finish with "Findwindow"

    I Think I solved That Now

    I have got a Professionally Written ClipBoard Source Code that I Think Uses API

    That I Hunted Down and Have Yet to USE

    It Seems a Pain in My Code That I have to Search

    For i = -30000 To 32000
        i2 =  Clipboard.GetFormat(i)
    Next
    

    To Test If False

    For ClipBoard-ed Object's in the Form Designer

    So they Don't Get Crippled or Interfere With My Code Program

    My ClipBoard Program Code is the Only Long Lasting Program Left that I Run Always

    For ClipBoards From the Internet Pages

    and It Takes / Logs Clip's of Pictures BitMaps of Screenshots and Things Storing in Date and Time Files

    I wish I Knew More about How to Get Drag and Drop Info Out

    Hope This Helps

    2015 Aug 14 8am-9am

    0 讨论(0)
  • 2020-12-01 14:38

    In the VB6 IDE go to Tools->Options->Editor and clear Drag-and-Drop Text Editing feature

    Thanks Matthew, you pointed me in the right direction, though I don't fully understand your issues

    I have an old VB6 project to rework, now able to edit and recompile OK on Windows 10, after the usual trauma of reregistering all the .ocx files. I run the VB6 through a shortcut with Properties->Advanced->Run As Administrator

    This error was persistent, popping up every time I started the VB6 IDE

    After reading Matthews post, I cleared the Drag-and-Drop Text Editing feature

    Shut down, restart VB6 and the error had gone

    Re-enabled Drag-and-Drop and still no error

    (Still living with the Automation Element Not Found Error)

    0 讨论(0)
提交回复
热议问题