I would like to abstract some program logic to a base class for executing a command-line program (functionality similar to what this question was requesting).
in oth
As was eventually disclosed during the commenting of the other answer, your BaseProgram
class is in a different assembly from the one you are trying to execute. The entry point of an assembly has to be in that assembly.
To do otherwise is like giving someone a key and telling them that's the key to your house's front door. Except the key is actually for some other completely different house's front door, so when they show up at your house it does them no good.
If you want to use the BaseProgram
's Main()
method, you need to delegate to it. For example, in your own assembly:
static class Program
{
public static int Main(string[] args)
{
return BaseProgram.Main(args);
}
}
Note that for static types or static members of types, there's no need to actually inherit the base type, since you just invoke it via the actual type name instead of an instance reference.