problem description
hierarchical decoupling, the most popular third-party open source framework Autofac
is very convenient to use on Web projects, just register the controller in MVC"s Application_Start.
but for applications such as WinForm and Console... Console aside, the entry of WinForm is in Program.Main, and new forms are created by direct instantiation, so it seems impossible to inject?
static void Main()
{
// ....
Application.Run(new Form1()); //
}
and Autofac
are not officially provided with expansion packs such as Autofac.Mvc5
.
so how to correctly use the Autofac
framework in WinForm (and Console) projects?