Click here to Skip to main content
15,885,870 members
Home / Discussions / C#
   

C#

 
GeneralRe: Help with file search Pin
turbosupramk320-Jan-11 13:12
turbosupramk320-Jan-11 13:12 
GeneralRe: Help with file search Pin
Not Active20-Jan-11 13:23
mentorNot Active20-Jan-11 13:23 
GeneralRe: Help with file search Pin
turbosupramk320-Jan-11 13:49
turbosupramk320-Jan-11 13:49 
AnswerRe: Help with file search Pin
Yusuf20-Jan-11 16:09
Yusuf20-Jan-11 16:09 
QuestionNodes, Script interface/ API and Undo Pin
adamvanner20-Jan-11 8:47
adamvanner20-Jan-11 8:47 
AnswerRe: Nodes, Script interface/ API and Undo Pin
SledgeHammer0120-Jan-11 9:51
SledgeHammer0120-Jan-11 9:51 
GeneralRe: Nodes, Script interface/ API and Undo Pin
adamvanner20-Jan-11 22:43
adamvanner20-Jan-11 22:43 
QuestionAccessing variables during AppDomain.ProcessExit Pin
thatdiceygirl20-Jan-11 5:16
thatdiceygirl20-Jan-11 5:16 

So currently I'm working on some code to dynamically trace the execution of methods in a separate DLL, once the methods complete, the trace of calls is written to a log file using a StreamWriter.

traceString = SeparateClass.TraceString;
traceFile.Write(traceString.ToString());
traceFile.Flush();
traceFile.Close()


traceFile being declared as a static global variale within the Program class.

However, some of the methods being traced, call the System.Environment.Exit(); command, which completely kill the entire app.

So...I want to use the AppDomain.ProcessExit Event handler to write the data to the log file and flush/close the file before it the app is killed.

I have defined a delegate to be set as the AppDomain.ProcessExit Event as follows...

testDomain.ProcessExit += delegate(object sender, EventArgs e)
{
  traceString = SeparateClass.TraceString;
  traceFile.Write(traceString.ToString());
  traceFile.Flush();
  traceFile.Close();
};


But...when the event is fired, I am getting NullReferenceExceptions at the first line, saying that SeparateClass is Null.

Are the values null and void as soon as AppDomain.ProcessExit is entered? If so, any idea how to close the file another way?

Thanks.

Jenni
A girl in Engineering AND IT?!...what is this nonsense?

AnswerRe: Accessing variables during AppDomain.ProcessExit Pin
Luc Pattyn20-Jan-11 5:46
sitebuilderLuc Pattyn20-Jan-11 5:46 
GeneralRe: Accessing variables during AppDomain.ProcessExit Pin
thatdiceygirl20-Jan-11 5:56
thatdiceygirl20-Jan-11 5:56 
AnswerRe: Accessing variables during AppDomain.ProcessExit Pin
Luc Pattyn20-Jan-11 6:05
sitebuilderLuc Pattyn20-Jan-11 6:05 
GeneralRe: Accessing variables during AppDomain.ProcessExit Pin
thatdiceygirl20-Jan-11 6:27
thatdiceygirl20-Jan-11 6:27 
AnswerRe: Accessing variables during AppDomain.ProcessExit Pin
Luc Pattyn20-Jan-11 6:37
sitebuilderLuc Pattyn20-Jan-11 6:37 
QuestionDatabase back up from asp.net Pin
yesu prakash20-Jan-11 1:02
yesu prakash20-Jan-11 1:02 
AnswerRe: Database back up from asp.net Pin
Richard MacCutchan20-Jan-11 1:54
mveRichard MacCutchan20-Jan-11 1:54 
GeneralRe: Database back up from asp.net Pin
yesu prakash20-Jan-11 17:15
yesu prakash20-Jan-11 17:15 
GeneralRe: Database back up from asp.net Pin
yesu prakash20-Jan-11 17:16
yesu prakash20-Jan-11 17:16 
GeneralRe: Database back up from asp.net Pin
Mahendra Vishwakarma20-Jan-11 20:37
Mahendra Vishwakarma20-Jan-11 20:37 
GeneralRe: Database back up from asp.net Pin
Richard MacCutchan20-Jan-11 21:30
mveRichard MacCutchan20-Jan-11 21:30 
QuestionRe: Database back up from asp.net Pin
Paladin200020-Jan-11 4:04
Paladin200020-Jan-11 4:04 
AnswerRe: Database back up from asp.net Pin
Mahendra Vishwakarma20-Jan-11 20:36
Mahendra Vishwakarma20-Jan-11 20:36 
QuestionSetup and File association Pin
Eduard Keilholz20-Jan-11 0:09
Eduard Keilholz20-Jan-11 0:09 
AnswerRe: Setup and File association Pin
GenJerDan20-Jan-11 3:40
GenJerDan20-Jan-11 3:40 
GeneralRe: Setup and File association Pin
Eduard Keilholz20-Jan-11 21:00
Eduard Keilholz20-Jan-11 21:00 
AnswerRe: Setup and File association Pin
J a a n s20-Jan-11 16:57
professionalJ a a n s20-Jan-11 16:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.