Cannot Call Non-Static Method from Static Method

Description

Static members can be called without creating a class instance. Non-static members can be called only for a class instance. When accessing a static member the instance of this class is not yet initialized, so its non-static methods cannot be used.

Troubleshooting Tips

Remove calling non-static members from the static members from the code. Perhaps, non-static members should be declared static.

Example

Class MyClass: Object
    Shared Sub Sub1;
    Begin
        Sub2;
    End Sub Sub1;
    
    Sub Sub2;
    Begin
        
    End Sub Sub2;
End Class MyClass;

When the specified code is compiled, the string where the procedure Sub2; is called displays the following error: Cannot call non-static method from static method. To resolve the error, delete calling the procedure Sub2 or declare this procedure a static one.

See also:

Compiler Messages