I used to think that an assembly could have only one main() method until I saw Jon Skeet's MiscUtil in a video lecture he delivered at the Microsoft office in Copenhagen.
So, I wrote this little app that had two main() methods like so:
namespace ManyMains
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello, World!");
Console.ReadKey();
}
}
class YetAnotherProgram
{
static void Main()
{
Console.WriteLine("Yet another program.");
Console.ReadKey();
}
}
}
I set the StartUp object in Visual Studio and it worked. Okay, no cause for distress. Then, I wanted to see where exactly this information is stored in the assembly, so I opened the compiled binary in reflector and saw absolutely no metadata to that effect.
I'm wondering if that sort of information is written into the manifest or some COFF header of the PE image that can't be seen in a disassembler but could be seen in a hex editor?