6

I just updated Ninject from v3 to v3.0.1.10 using NuGet, and it broke my code. I can't find IKernel.Get, or related methods I depended on anywhere in the new library. I've scoured the Ninject website and blogs and came up short, I couldn't find a detailed changelog. I noticed there is a Resolve IEnumerable method... is this the only way to retrieve objects now? What happened to the Generics, and single-instance Resolve/Get methods?

Martin Bliss
  • 1,043
  • 7
  • 24

2 Answers2

10

Nah, select isnt broken.

Most things in Ninject are extension methods. Are you using Ninject; ?

When you use Ctrl-Alt-O to look at your full compile errors, are you sure you're not getting an earlier error preventing the Ninject assembly from being loaded properly?

Ruben Bartelink
  • 59,778
  • 26
  • 187
  • 249
  • As I said before, the new DLL broke my existing code that was working with the previous Ninject 3.0 build. If I hold a reference to IKernel, I should also see it's extension methods (since they're both in the same namespace.) Switching out the new DLL for the old resolves the issue so I'm inclined to think something is wrong with 3.0.1.10. Still, I'll take a closer look when I get in the office on Monday. – Martin Bliss Nov 03 '12 at 04:13
  • I can assure you there is absolutely no way that [select is broken](http://www.codinghorror.com/blog/2008/03/the-first-rule-of-programming-its-always-your-fault.html) - the Ninject committers use [Semantic Versioning](http://semver.org/) to communicate change impacts. There's an assembly redirect broken or missing or a `using` missing, trust me. (Circumstancial evidence: I'm pretty sure I've migrated between the versions you cite myself) – Ruben Bartelink Nov 03 '12 at 08:54
  • 1
    The reason I mention the `using` is that if you "hold a reference to `IKernel`", the extension methods in the same namespace as `IKernel` are __NOT__ visible by default without a `using`. – Ruben Bartelink Nov 03 '12 at 08:56
  • Now that I'm in the office I can dive into this further. The problem is that my Intellisense/ReSharper isn't working correctly. It's saying the extension methods don't exist, BUT the project builds and I can run the code and select a service if I "pretend" the method exists with the standard .Get<>() method signature. I'm thinking something must be up with VS2012. Any ideas before I close this question and ask another, specific to VS12? – Martin Bliss Nov 05 '12 at 13:36
  • Nevermind. I figured it out. This is a ReSharper bug. http://stackoverflow.com/questions/5539131/resharper-cannot-resolve-symbol-eval-in-vs2010-sp1 – Martin Bliss Nov 05 '12 at 14:05
  • Adding "using Ninject;" to the top of the file fixed it for me - it is not added automatically with the Kernel declaration. Thanks for the help! – Guy Starbuck Aug 19 '14 at 16:17
1

Turns out to be related to my using ReSharper, and NOT Ninject. Sometimes ReSharper will miss methods, properties, etc... in scanning a solution, and deleting the cache is the only way to get ReSharper to scan again.

Resharper: Cannot resolve symbol 'Eval' in VS2010 SP1

Community
  • 1
  • 1
Martin Bliss
  • 1,043
  • 7
  • 24