static public string writeexceptionrecord( exception e ) {
try {
string filename = path.combine( application.startuppath, "error.log" );
streamwriter sw = new streamwriter( filename, true );
sw.writeline( "errorlog.writeexceptionlog() >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" );
try {
datetime now = datetime.now;
sw.writeline( "currentdate: " + now.tolongdatestring() );
sw.writeline( "currenttime: " + now.tolongtimestring() );
sw.flush();
}
catch( exception ex ) {
sw.writeline( "<error-currentdatetime>" + ex.tostring() );
}
try {
sw.writeline( "exception.type: " + e.gettype().name );
sw.writeline( "exception.message: " + e.message );
sw.writeline( "exception.source: " + e.source );
sw.writeline( "exception.helplink: " + e.helplink );
sw.writeline( "exception.targetsite: " + e.targetsite );
sw.writeline( "exception.stacktrace: " );
sw.writeline( e.stacktrace );
sw.flush();
}
catch( exception ex ) {
sw.writeline( "<error-exception>" + ex.tostring() );
}
try {
sw.writeline( "gc.totalmemory: " + gc.gettotalmemory( false ) );
sw.flush();
}
catch( exception ex ) {
sw.writeline( "<error-gc>" + ex.tostring() );
}
try {
sw.writeline( "application.productname: " + application.productname );
sw.writeline( "application.productversion: " + application.productversion );
sw.writeline( "application.startuppath: " + application.startuppath );
sw.writeline( "application.executablepath: " + application.executablepath );
sw.writeline( "application.currentdirectory: " + directory.getcurrentdirectory() );
sw.flush();
}
catch( exception ex ) {
sw.writeline( "<error-application>" + ex.tostring() );
}
try {
assembly execassembly = assembly.getexecutingassembly();
sw.writeline( "executingassembly.codebase: " + execassembly.codebase );
sw.writeline( "executingassembly.location: " + execassembly.location );
sw.writeline( "executingassembly.globalassemblycache: " + execassembly.globalassemblycache );
sw.flush();
}
catch( exception ex ) {
sw.writeline( "<error-executingassembly>" + ex.tostring() );
}
try {
foreach( string watchname in s_htwatches.keys ) {
sw.writeline( "watch[" + watchname + "]: " + getwatchstring( watchname ) );
}
sw.flush();
}
catch( exception ex ) {
sw.writeline( "<error-watches>" + ex.tostring() );
}
try {
foreach( logentry logentry in s_logentries ) {
sw.writeline( "logentry" + logentry.tostring() );
}
sw.flush();
}
catch( exception ex ) {
sw.writeline( "<error-logentry>" + ex.tostring() );
}
try {
assembly selfassembly = assembly.getassembly( typeof( bugtracking ) );
sw.writeline( "currentassembly.codebase: " + selfassembly.codebase );
sw.writeline( "currentassembly.location: " + selfassembly.location );
sw.writeline( "currentassembly.globalassemblycache: " + selfassembly.globalassemblycache );
sw.flush();
}
catch( exception ex ) {
sw.writeline( "<error-currentassembly>" + ex.tostring() );
}
try {
thread thread = thread.currentthread;
sw.writeline( "currentthread.name: " + thread.name );
sw.writeline( "currentthread.priority: " + thread.priority );
sw.flush();
}
catch( exception ex ) {
sw.writeline( "<error-currentthread>" + ex.tostring() );
}
try {
process process = process.getcurrentprocess();
sw.writeline( "currentprocess.name: " + process.processname );
sw.writeline( "currentprocess.machinename: " + process.machinename );
sw.writeline( "currentprocess.mainmodule: " + process.mainmodule );
sw.writeline( "currentprocess.startdate: " + process.starttime.tolongdatestring() );
sw.writeline( "currentprocess.starttime: " + process.starttime.tolongtimestring() );
sw.writeline( "currentprocess.userprocessortime: " + process.userprocessortime );
sw.writeline( "currentprocess.totalprocessortime: " + process.totalprocessortime );
sw.flush();
}
catch( exception ex ) {
sw.writeline( "<error-currentprocess>" + ex.tostring() );
}
try {
operatingsystem os = environment.osversion;
sw.writeline( "environment.osversion.platform: " + os.platform );
sw.writeline( "environment.osversion.version: " + os.version );
version ver = environment.version;
sw.writeline( "environment.version.major: " + ver.major );
sw.writeline( "environment.version.minor: " + ver.minor );
sw.writeline( "environment.version.revision: " + ver.revision );
sw.writeline( "environment.version.build: " + ver.build );
sw.writeline( "environment.username: " + environment.username );
sw.writeline( "environment.systemdirectory: " + environment.systemdirectory );
sw.writeline( "environment.tickcount: " + environment.tickcount );
sw.writeline( "environment.commandline: " + environment.commandline );
sw.writeline( "environment.workingset: " + environment.workingset );
string[] args = environment.getcommandlineargs();
if( args != null ) {
for( int i = 0; i < args.length; i ++ ) {
sw.writeline( "environment.commandlineargs[" + i + "]: " + args[i] );
}
}
sw.writeline( "environment.stacktrace: " );
sw.writeline( environment.stacktrace );
sw.flush();
}
catch( exception ex ) {
sw.writeline( "<error-environment>" + ex.tostring() );
}
sw.writeline( "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" );
sw.close();
return filename;
}
catch( exception ) {
return "– error writing log file –";
}
}
