A
Andy
Beats me what is causing this. I've been banging my head against the
wall for several days now.
I have a csharp program that launches a long process that resides in
another application. My program has to wait for the output of the
other application, so I use a customized JobTimer based on the
System.Timers.Timer class to poll the other application for the status
of its job. I believe the timer and its callback function run on a
different thread than my program does, and the other application runs
on another machine.
When the application's job completes, one of my timer cycles detects
the job's status and the callbackmethod the timer calls resumes my
program's processing. My callbackmethod invokes a static method in
another non-static class. But, when this method is invoked, it throws
a TypeInitializationException without the function ever being
executed. The innerexception reports the following message:
Object reference not set to an instance of an object
The call looks like:
myNonStaticProgram{
myNonStaticCallbackMethod(){
myOtherNonStaticClass.staticFunction();
}
}
myOtherNonStaticClass{
public static staticFunction()
{
//debugger never steps into here
}
}
There are no further innerexceptions. What is puzzling is that the
same call does not throw a typeInitializationException if made from
anywhere else other than the timer's callback function. It almost
looks like the static object doesn't exist anymore by the time the
callbackfunction is activated.
Does anyone know what could be going wrong?
Andy
wall for several days now.
I have a csharp program that launches a long process that resides in
another application. My program has to wait for the output of the
other application, so I use a customized JobTimer based on the
System.Timers.Timer class to poll the other application for the status
of its job. I believe the timer and its callback function run on a
different thread than my program does, and the other application runs
on another machine.
When the application's job completes, one of my timer cycles detects
the job's status and the callbackmethod the timer calls resumes my
program's processing. My callbackmethod invokes a static method in
another non-static class. But, when this method is invoked, it throws
a TypeInitializationException without the function ever being
executed. The innerexception reports the following message:
Object reference not set to an instance of an object
The call looks like:
myNonStaticProgram{
myNonStaticCallbackMethod(){
myOtherNonStaticClass.staticFunction();
}
}
myOtherNonStaticClass{
public static staticFunction()
{
//debugger never steps into here
}
}
There are no further innerexceptions. What is puzzling is that the
same call does not throw a typeInitializationException if made from
anywhere else other than the timer's callback function. It almost
looks like the static object doesn't exist anymore by the time the
callbackfunction is activated.
Does anyone know what could be going wrong?
Andy