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

后端 未结 8 1780
耶瑟儿~
耶瑟儿~ 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:39

    I have VB6 SP6 and I can reproduce this behavior. In a fresh project, put this code into a form. The project runs normally with F5. Right click the project and select Publish then Build Outputs. This generates the error message.

    Option Explicit
    
    Public Sub Init()
        Dim blnErrorHandling As Boolean
    
        If False Then
            blnErrorHandling = True
        Else
            blnErrorHandling = False
    End Sub
    

    Now comment out the last four lines:

    Option Explicit
    
    Public Sub Init()
        Dim blnErrorHandling As Boolean
    
    '    If False Then
    '        blnErrorHandling = True
    '    Else
    '        blnErrorHandling = False
    End Sub
    

    You no longer get the error and the outputs are built normally. I was quickly adding in some error handling to locate the source of a crash and If False Then is perfectly valid. The MDAC checker said all was ok and a reboot didn't solve the problem.

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

    For a VB6 program which is run as a command line application there is an extra stage required after compilation: the VB6 linker needs to be run on the executable to set it as a console program:

    <VB6 dir>\LINK.EXE  /EDIT  /SUBSYSTEM:CONSOLE  <program>.exe
    

    Failure to do this will give the Method '~' of object '~' failed error when the program is run.

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