Using Autofac to inject a dependency into the Main entry point in a console app
问题 Say I have a simple console application: public static class Program { private static ILog Log { get; set; } public static void Main() { Log.Write("Hello, world!"); } } What is the simplest way I can use Autofac to inject the Log instance and ensure that the Log property will not be null at run time? The issue is that I can't pass it in through Main() and I'm trying to avoid service location using the container (just because). 回答1: What you should do is extract all logic from your main into a