if you move your VO application to X#, unfortunately your error handler will not more work.
Therefore you should change your Start module as follows:
Code: Select all
function Start() as int
local oXApp as XApp
AppDomain.CurrentDomain:UnhandledException += VOXSErrorHandler.UnhandledException
try
oXApp := XApp{}
oXApp:Start()
catch oException as Exception
VOXSErrorHandler.ProcessException( oException )
end try
return 0
Code: Select all
using System.Text
using System.IO
using System.Reflection
static class VOXSErrorHandler
static constructor()
return
static method UnhandledException( Sender as object, e as UnhandledExceptionEventArgs ) as void
VOXSErrorHandler.ProcessException( ( Exception ) e:ExceptionObject )
return
static method ProcessException( oException as Exception ) as void
local cMessage as string
cMessage := oException:Message
VOXSErrorHandler.WriteErrorLog( oException )
do while oException:InnerException != NULL_OBJECT
oException := oException:InnerException
VOXSErrorHandler.WriteErrorLog( oException )
cMessage += CRLF + oException:Message
enddo
VOXSErrorHandler.ErrBox( cMessage )
return
static method WriteErrorLog( oException as Exception ) as void
local cFileName as string
local cErrorText as string
local oSB as StringBuilder
cFileName := Path.Combine( AppDomain.CurrentDomain:BaseDirectory, "XSharpError.log" )
oSB := StringBuilder{ String.Format( "Error occurred in {0} at {1}", ;
Assembly.GetEntryAssembly():Location, DateTime.Now:ToString() ) }
oSB:AppendLine( "------------------------------------------------------------" )
oSB:AppendLine( oException:Message )
oSB:AppendLine( "Callstack:" )
oSB:AppendLine( oException:StackTrace )
oSB:AppendLine( "" )
File.AppendAllText( cFileName, oSB:ToString() )
return
static method ErrBox( cText as string ) as void
local oParent as object
local oBox as TextBox
oParent := GetObjectByHandle( GetActiveWindow() )
if oParent == null_object
oParent := nil
endif
oBox := TextBox{ oParent, "Error", cText }
oBox:Type := BOXICONHAND
oBox:Beep := true
oBox:Show()
return
end class
Hope this helps someone!
Wolfgang