
How do I prevent the error dialog from blocking a compiled standalone application from exiting?
20 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
MathWorks Support Team
el 31 de Mzo. de 2020
Editada: MathWorks Support Team
el 16 de Dic. de 2025 a las 20:26
When there is an uncaught exception in a standalone application, an error dialog window appears that blocks the program until the user closes the dialog window manually.
Respuesta aceptada
MathWorks Support Team
el 16 de Dic. de 2025 a las 0:00
Editada: MathWorks Support Team
el 16 de Dic. de 2025 a las 20:26
There are two solutions for this: Either enable displaying to the shell or catch the exception and terminate the program.
When the "Do not display the Windows Command Shell (console) for execution" check box under "Additional runtime settings" in the Application Compiler GUI is checked, or if you compile with "mcc" using "-e" (or "-W WinMain -T link:exe"), then error messages will be rerouted to a dialog box. Enabling displaying to shell will display the error in the shell from which the program is run. For more information, refer to the following MathWorks documentation on mcc Command Line Arguments Grouped by Tasks.

Alternatively, if you would like to terminate the application when there is an uncaught error only in the deployed application, then you can wrap your code in a try-catch block, and in the catch block, do any necessary logging and call quit/exit with the appropriate exit code after checking if the script is deployed:
try
myProgramScript;
catch E
% do something with caught exception
if isdeployed
quit(-1)
end
end
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Application Deployment en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!