我们正在尝试通过ninjectwebcommon.cs进行调试,以找到存储库的绑定。在VS 2012中,我将Debugpoint放置在kernel.bind上,但是它没有随时可用。有人可以建议我如何调试吗?
我有NInject版本v4.0.30319
Ninject是开源的。您可以从https://github.com/ninject的Github页面下载整个项目。从那里,您可以将Visual Studio指向那些项目,而不是使用已编译的程序集。
另一种选择是将http://symbolsource.org用作符号服务器。但看起来他们只有Ninject 3。
对我来说不是那么简单和(显然)的临时解决方案是使用我正在调试的配置在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
方法的其余部分,从而允许应用程序启动并允许调试器进行附加。