I solved this problem by saving each open window in SSMS using the Save button. After saving the first one without any error, the program works fine.