With all the updates pouring out of Microsoft these days within .NET land, I have been checking out their latest offerings within some of my own projects.
So far, it has been a breeze to setup a self-hosted application, and the fact that MVC no longer uses System.Web is a wonderful thing. Recently, I wanted to try out a new (to me) dependency injector. It is a sad thing to say, but, many projects I have worked have not used DI (which has led to a lot of workaround, hackarounds, etc.), so, while I understand the concepts, I haven’t had the pleasure of using DI fully across a project. Now was my chance.
After doing a bit of researching, I settled on Ninject. I like the fact that it is lightweight, is very modular in structure, good documentation, and, of course, ninjas are always cool. (Pro Tip: If you ever play Superfight with me, the Ninja will always win the fight. Hands down.)
As I said, it has excellent documentation. Because I am using OWIN, I followed [this set of instructions]https://github.com/ninject/Ninject.Web.Common/wiki/Setting-up-a-OWIN-WebApi-application. Unfortunately, I ran into a little issue.
It turns out, that, because I am using the latest version of Microsoft.Owin, which is 3.0.1 at the time of this writing. However, the latest stable version of Ninject OWIN host for WebApi 2 has a set of dependencies that will depend on Microsoft.Owin 2.0.0.
Now, I realize the instructions on the Ninject website that I linked up above say to specifically install Ninject.Web.Common.OwinHost and Ninject.Web.WebApi.OwinHost. For some reason, I decided to look at the second, saw that Ninject.Web.Common.OwinHost was a dependency, and just decided to install that and allow everything else to fall out. In fact, when I ran into this problem, I mapped out the dependency tree. Here it is:
As you can see, everything looks good for any reference to Microsoft.Owin across the board. In fact, I am a bit stumped as to how I ran into this issue in the first place. (If I get Ninject.Web.WebApi.OwinHost version 3.2.3, a dependency exists that requires a version < 3 of Microsoft.Owin, but, that doesn’t make sense based on the above dependency tree.) If anybody has any insight, would really appreciate further clarification in the comments below.
Maybe the lesson to learn here is, next time, I should listen to the instructions and install each package separately and in the right order.comments powered by Disqus