Skip to content

Instantly share code, notes, and snippets.

@graylikeme
Created April 16, 2011 23:34
Show Gist options
  • Select an option

  • Save graylikeme/923618 to your computer and use it in GitHub Desktop.

Select an option

Save graylikeme/923618 to your computer and use it in GitHub Desktop.
Ninject MVC3 loader in VB(NinjectMVC3.vb)
Imports Microsoft.Web.Infrastructure.DynamicModuleHelper
Imports Ninject
Imports Ninject.Web.Mvc
<Assembly: WebActivator.PreApplicationStartMethod(GetType(applicationName.App_Start.NinjectMVC3), "StartNinject")>
<Assembly: WebActivator.ApplicationShutdownMethodAttribute(GetType(applicationName.App_Start.NinjectMVC3), "StopNinject")>
Namespace applicationName.App_Start
Public Module NinjectMVC3
Private ReadOnly bootstrapper As New Bootstrapper()
''' <summary>
''' Starts the application
''' </summary>
Public Sub StartNinject()
DynamicModuleUtility.RegisterModule(GetType(OnePerRequestModule))
bootstrapper.Initialize(AddressOf CreateKernel)
End Sub
''' <summary>
''' Stops the application.
''' </summary>
Public Sub StopNinject()
bootstrapper.ShutDown()
End Sub
''' <summary>
''' Creates the kernel that will manage your application.
''' </summary>
''' <returns>The created kernel.</returns>
Private Function CreateKernel() As IKernel
Dim kernel = New StandardKernel()
RegisterServices(kernel)
Return kernel
End Function
''' <summary>
''' Load your modules or register your services here!
''' </summary>
''' <param name="kernel">The kernel.</param>
Private Sub RegisterServices(ByVal kernel As IKernel)
End Sub
End Module
End Namespace
@graylikeme
Copy link
Copy Markdown
Author

really? i'll check this out at the morning, but as far as i'm concerned that when you install through nuget then everything should work as a charm

@schmidlop
Copy link
Copy Markdown

schmidlop commented Apr 29, 2012 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment