I just discovered why I was getting a mysterious -609 ("Connection is invalid") error in Mt Lion (10.8.2).
To see the problem:
1. Compile this script as an application bundle named "main.app"
on run
activate me
tell me to display dialog "Running" buttons {"OK"} default button 1
end run
on doSomethingElse()
activate me
tell me to display dialog "What do you want to do?" buttons {"OK"} default button 1
end doSomethingElse
2. Compile this script as an application bundle named "CallingApp.app"
property hostAppl : "OSX_Mt_Lion:Bug Check:main.app"
on run
try
launch application hostAppl
tell application hostAppl to doSomethingElse() -- comment out and see what happens
on error errText number errNr
activate me
"CallingApp Error = " & errNr & return & errText
tell me to display dialog the result buttons {"OK"} default button 1
end try
end run -----------------------------
Double-click the application "CallingApp.app".
In Lion, you will get a dialog asking "What do you want to do?". This is the correct action.
In Mt Lion, you get …
1. The "Running" dialog, then
2. The error dialog "CallingApp Error = =609"
The 'launch application' command is designed to open an application WITHOUT executing the run handler. That is its purpose. This is broken in Mt Lion. I think this is a really serious bug.