how to get better (any?) diagnostics out of ninject why its throwing ActivationException?

做~自己de王妃 提交于 2019-12-12 19:10:01

问题


Ok, so I am using both Automapper (LOVE it!) and ninject (very fond of it, but we have "issues" :-). I am writing MVC3 apps.

When I mess something up in Automapper configuration, Automapper goes to great lengths to tell me exactly what I did wrong, providing all necessary details.

When I mess something up in ninject configuration, it says "something is wrong". Well, not even quite that. If I am lucky enough to have the output window open, I hopefully see a message fly by akin to "first chance exception ActivationException was thrown". Thats it.

Not very helpful if you ask me...

Is there a way to get ninject to be a little more communicative? Right now, I have a list of things I check (make sure ctor is public, make sure the class implements all of the interface, etc etc).


回答1:


Aha! Found the issue.

Turns out that I am using TryGet(), which implicitly catches any exceptions ninject throws. This explains why although I saw a message about a first chance exception in the output log, but nothing was actually thrown.

Switching over to using a Get() lets the exception bubble up.

Now theres a whole lotta love im gettin' from ninject about the error in my ways ==> very useful diagnostic debug output.

Hope this helps another soul with the same confusion.



来源:https://stackoverflow.com/questions/8239284/how-to-get-better-any-diagnostics-out-of-ninject-why-its-throwing-activatione

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!