'StandardKernel' 已过时:`使用 StandardKernelConfiguration 和 StandardReadonlyKernel`

'StandardKernel' is obsolete: `Use StandardKernelConfiguration and StandardReadonlyKernel`

我想在我的Windows服务程序中使用ninject(4.0.0版本)解决依赖,我看过quite a few tutorials,他们都使用StandardKernel 初始化 ninject 内核如下:

IKernel kernel = new StandardKernel();
kernel.Load(Assembly.GetExecutingAssembly());

但是我在使用 StandardKernel 时收到以下警告:

'StandardKernel' is obsolete: 'Use StandardKernelConfiguration and StandardReadonlyKernel'

任何人都可以使用 StandardKernelConfigurationStandardReadonlyKernel 举个例子吗?

我没有意识到 ninject 版本 4.0.0 处于测试阶段,但以下语法对我有用:

IReadOnlyKernel kernel = new KernelConfiguration(new MyModule()).BuildReadonlyKernel();