User Tools

Site Tools


codesamples:exception_handling_program_startup

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
codesamples:exception_handling_program_startup [2024/09/16 04:32] wolfgangriedmanncodesamples:exception_handling_program_startup [2024/09/16 09:06] (current) wolfgangriedmann
Line 7: Line 7:
 class XStartupCode class XStartupCode
 [STAThreadAttribute]; [STAThreadAttribute];
-static method Start as void+static method Start() as void strict
   local oSB as System.Text.StringBuilder   local oSB as System.Text.StringBuilder
  
   try   try
  
-  Functions.Start()+  StartupExceptionTester.Exe.Functions.Start()
  
   catch oEx as Exception   catch oEx as Exception
Line 29: Line 29:
   Output( oSB, "===================================" )   Output( oSB, "===================================" )
   Output( oSB, "Press Return to close the application" )   Output( oSB, "Press Return to close the application" )
-  Wait()+  Console.ReadLine()
   MessageBox( 0, oSB:ToString(), "Runtime error", 0 )   MessageBox( 0, oSB:ToString(), "Runtime error", 0 )
   System.IO.File.AppendAllText( System.IO.Path.Combine( AppDomain.CurrentDomain:BaseDirectory, "ApplicationError.log" ), oSB:ToString() )   System.IO.File.AppendAllText( System.IO.Path.Combine( AppDomain.CurrentDomain:BaseDirectory, "ApplicationError.log" ), oSB:ToString() )
Line 40: Line 40:
   oSB:AppendLine( cText )   oSB:AppendLine( cText )
   Console.WriteLine( cText )   Console.WriteLine( cText )
- 
-  return 
- 
-static method Wait() as void 
- 
-  Console.ReadLine() 
  
   return   return
Line 61: Line 55:
 <code>-main:XStartupCode</code> <code>-main:XStartupCode</code>
 Please see here for a sample as XIDE application export file: Please see here for a sample as XIDE application export file:
-[[https://docs.xsharp.it/doku.php?ns=download%3A&image=download%3Astartupexceptiontester.zip|startupexceptiontester.zip]]+[[https://docs.xsharp.it/lib/exe/fetch.php?media=download:startupexceptiontester.zip|startupexceptiontester.zip]] 
 + 
 +For a native .NET application with namespaces the code changes a bit: 
 +<code>class ProdPlan.XStartupCode 
 + 
 +[STAThreadAttribute]; 
 +static method Start as void 
 +local oSB as System.Text.StringBuilder</code> 
 +where ''ProdPlan'' is the namespace of your application. 
 +The compiler option than has to be 
 +<code>-main:ProdPlan.XStartupCode</code> 
 + 
 +To explain: since the GUI can be not yet started when an exception is occurring, the console mode needs to be activated so the error can be shown even with no GUI (and written to a file for later evaluation).
  
codesamples/exception_handling_program_startup.1726461134.txt.gz · Last modified: 2024/09/16 04:32 by wolfgangriedmann