I had the following case, and thought of sharing the solution with you:
I got the following two error messages:
Error Message in program class: you are not connected to a company
Error Code: -131, ErrorMessage: Connection to license server failed; if license server address is invalid, correct it; if TAO NT naming service stopped, activate it and restart License Manager
I was sure that all SAP B1, and MS SQL services are up, and running on the server side so I knew this is an issue related to the client side.
The solution was checking the file “b1-local-machine” which is located it under “C:\program files\SAP\SAP Business One DI API\Conf”
The value of the server ip was “localhost”, and it should be the ip of my production server instead.
Hope that was helpful.