0

We are trying to debug through ninjectwebcommon.cs to find the binding for a respository. In VS 2012, I am putting a Debugpoint on the kernel.bind but it doesnot hit anytime. Can someone sugggest me how to debug this?

I have NInject Version v4.0.30319

2 Answers2

1

The not-so-simple and (obviously) temporary solution for me was to create a background thread in NinjectWebCommon.RegisterServices with the configuration I was debugging:

var thread = new System.Threading.Thread(() =>
{
  while (!System.Diagnostics.Debugger.IsAttached)
  {
    System.Threading.Thread.Sleep(100);
  }

  // custom code, including kernel.Bind<>() calls here
});

thread.IsBackground = true;
thread.Start();

The idea here is to keep the thread you've created from executing the debuggable code until the debugger is actually attached. Setting the IsBackground property is important, because this allows the rest of the RegisterServices method to complete, which in turn allows the application to start and allows the debugger to attach.

Adrian Anttila
  • 2,038
  • 5
  • 22
  • 25
0

Ninject is open source. You can download the entire project from their Github page at https://github.com/ninject. From there you can point Visual Studio to those projects instead of using the compiled assemblies.

Another option would be to use http://symbolsource.org as a Symbol Server. But it looks like they only have Ninject 3.

Steven V
  • 16,357
  • 3
  • 63
  • 76
  • I believe the actual problem here is that NinjectWebCommon used WebActivatorEx to integrate into the application lifecycle, and by the time Visual Studio can attach its debugger, that code has already run. – Adrian Anttila Oct 29 '19 at 19:34