如何调试NinjectWebCommon.cs?

问题描述 投票:0回答:2

我们正在尝试通过ninjectwebcommon.cs进行调试,以找到存储库的绑定。在VS 2012中,我将Debugpoint放置在kernel.bind上,但是它没有随时可用。有人可以建议我如何调试吗?

我有NInject版本v4.0.30319

asp.net-mvc-4 ninject.web.mvc
2个回答
0
投票

Ninject是开源的。您可以从https://github.com/ninject的Github页面下载整个项目。从那里,您可以将Visual Studio指向那些项目,而不是使用已编译的程序集。

另一种选择是将http://symbolsource.org用作符号服务器。但看起来他们只有Ninject 3。


0
投票

对我来说不是那么简单和(显然)的临时解决方案是使用我正在调试的配置在NinjectWebCommon.RegisterServices中创建一个后台线程:

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();

这里的想法是使您创建的线程不执行可调试代码,直到实际连接调试器为止。设置IsBackground属性很重要,因为这可以完成RegisterServices方法的其余部分,从而允许应用程序启动并允许调试器进行附加。

© www.soinside.com 2019 - 2024. All rights reserved.