I'm trying to inherit subclass from System.Diagnost ics.Process, but
whenever I cast a "Process" object to it's subclass, I encounter an
exception "System.Invalid CastException" ("Specified cast is not
valid"). How do I fix it ?
using System.Diagnost ics;
..
..
class NewProcess: Process
{
public override String ToString()
{
return this.ProcessNam e;
}
}
..
..
Process p, n;
p = new Process;
DoSomethingOnPr ocess (p);
n = (NewProcess) p; // throws System.InvalidC astException:
Specified cast is not valid
..
..
..
Thank you in advance, for any help.
whenever I cast a "Process" object to it's subclass, I encounter an
exception "System.Invalid CastException" ("Specified cast is not
valid"). How do I fix it ?
using System.Diagnost ics;
..
..
class NewProcess: Process
{
public override String ToString()
{
return this.ProcessNam e;
}
}
..
..
Process p, n;
p = new Process;
DoSomethingOnPr ocess (p);
n = (NewProcess) p; // throws System.InvalidC astException:
Specified cast is not valid
..
..
..
Thank you in advance, for any help.
Comment