LayerNames returns empty list after Open command launch from modeless dialog?

Thank you very much Dale! That was exactly the problem!

I renamed the title of the post to help people with similar problem find this solution more easily :wink: