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