barkermn01
05-18-2009, 01:47 PM
Hi, for some reason the system.IO wont work in a class,
This is my class now when i call log.start() it works and adds the text, but when i call log.WriteLine my application freezes and i get this error and debug info,
Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object.
at CRM_Server_TEST.log.WriteLine(String output)
at CRM_Server_TEST.Program.showHelp()
at CRM_Server_TEST.Program.inputText()
at CRM_Server_TEST.Program.Main(String[] args)
class log
{
public TextWriter tw;
public void start()
{
tw = new StreamWriter("logs.log");
tw.WriteLine("Logs started at " + DateTime.Now);
}
public void end()
{
tw.Close();
}
public void WriteLine(string output)
{
tw.WriteLine(output);
}
}
This is my class now when i call log.start() it works and adds the text, but when i call log.WriteLine my application freezes and i get this error and debug info,
Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object.
at CRM_Server_TEST.log.WriteLine(String output)
at CRM_Server_TEST.Program.showHelp()
at CRM_Server_TEST.Program.inputText()
at CRM_Server_TEST.Program.Main(String[] args)
class log
{
public TextWriter tw;
public void start()
{
tw = new StreamWriter("logs.log");
tw.WriteLine("Logs started at " + DateTime.Now);
}
public void end()
{
tw.Close();
}
public void WriteLine(string output)
{
tw.WriteLine(output);
}
}