<?xml version="1.0"?><?xml-stylesheet type="text/xsl" href="/rss.xsl"?><rss version="2.0"><channel><title>ninject Issue Tracker Rss Feed</title><link>http://ninject.codeplex.com/WorkItem/List.aspx</link><description>ninject Issue Tracker Rss Description</description><item><title>Commented Issue: NullReferenceException on Bind&lt;T&gt; [4038]</title><link>http://ninject.codeplex.com/WorkItem/View.aspx?WorkItemId=4038</link><description>When doing a my first Bind&amp;#60;T&amp;#62; call in my application, I get the following stacktrace&amp;#58;&lt;br /&gt;&lt;br /&gt;&amp;#91;NullReferenceException&amp;#58; Object reference not set to an instance of an object.&amp;#93;&lt;br /&gt;   Ninject.Core.Infrastructure.DebugInfo.ShouldIgnoreType&amp;#40;Type type&amp;#41; in d&amp;#58;&amp;#92;Projects&amp;#92;Ninject&amp;#92;src&amp;#92;Core&amp;#92;Infrastructure&amp;#92;Debugging&amp;#92;DebugInfo.cs&amp;#58;156&lt;br /&gt;   Ninject.Core.Infrastructure.DebugInfo.FromStackTrace&amp;#40;&amp;#41; in d&amp;#58;&amp;#92;Projects&amp;#92;Ninject&amp;#92;src&amp;#92;Core&amp;#92;Infrastructure&amp;#92;Debugging&amp;#92;DebugInfo.cs&amp;#58;128&lt;br /&gt;   Ninject.Core.ModuleBase&amp;#96;1.DoBind&amp;#40;Type type&amp;#41; in d&amp;#58;&amp;#92;Projects&amp;#92;Ninject&amp;#92;src&amp;#92;Core&amp;#92;Modules&amp;#92;ModuleBase.cs&amp;#58;269&lt;br /&gt;   Ninject.Core.ModuleBase&amp;#96;1.Bind&amp;#40;&amp;#41; in d&amp;#58;&amp;#92;Projects&amp;#92;Ninject&amp;#92;src&amp;#92;Core&amp;#92;Modules&amp;#92;ModuleBase.cs&amp;#58;116&lt;br /&gt;   SettingsModule.Load&amp;#40;&amp;#41; in x&amp;#58;&amp;#92;workspace&amp;#92;tour-manager&amp;#92;web&amp;#92;App_Code&amp;#92;NtmApp.cs&amp;#58;62&lt;br /&gt;   Ninject.Core.KernelBase.LoadModules&amp;#40;IEnumerable&amp;#96;1 modules&amp;#41; in d&amp;#58;&amp;#92;Projects&amp;#92;Ninject&amp;#92;src&amp;#92;Core&amp;#92;KernelBase.cs&amp;#58;358&lt;br /&gt;   Ninject.Core.KernelBase.Load&amp;#40;IModule&amp;#91;&amp;#93; modules&amp;#41; in d&amp;#58;&amp;#92;Projects&amp;#92;Ninject&amp;#92;src&amp;#92;Core&amp;#92;KernelBase.cs&amp;#58;173&lt;br /&gt;   NtmApp..cctor&amp;#40;&amp;#41; in x&amp;#58;&amp;#92;workspace&amp;#92;tour-manager&amp;#92;web&amp;#92;App_Code&amp;#92;NtmApp.cs&amp;#58;36&lt;br /&gt;&lt;br /&gt;I&amp;#39;m a novice at Ninject, so I might be missing something basic, but this seems like an internal error&amp;#63;&lt;br /&gt;Comments: ** Comment from web user: liedman ** &lt;p&gt;Problems appears to be that my classes NtmApp and SettingsModule are not inside any namespace. Moving them inside a namespace fixes the issue.&lt;/p&gt;</description><author>liedman</author><pubDate>Mon, 15 Feb 2010 16:43:36 GMT</pubDate><guid isPermaLink="false">Commented Issue: NullReferenceException on Bind&lt;T&gt; [4038] 20100215044336P</guid></item><item><title>Created Issue: NullReferenceException on Bind&lt;T&gt; [4038]</title><link>http://ninject.codeplex.com/WorkItem/View.aspx?WorkItemId=4038</link><description>When doing a my first Bind&amp;#60;T&amp;#62; call in my application, I get the following stacktrace&amp;#58;&lt;br /&gt;&lt;br /&gt;&amp;#91;NullReferenceException&amp;#58; Object reference not set to an instance of an object.&amp;#93;&lt;br /&gt;   Ninject.Core.Infrastructure.DebugInfo.ShouldIgnoreType&amp;#40;Type type&amp;#41; in d&amp;#58;&amp;#92;Projects&amp;#92;Ninject&amp;#92;src&amp;#92;Core&amp;#92;Infrastructure&amp;#92;Debugging&amp;#92;DebugInfo.cs&amp;#58;156&lt;br /&gt;   Ninject.Core.Infrastructure.DebugInfo.FromStackTrace&amp;#40;&amp;#41; in d&amp;#58;&amp;#92;Projects&amp;#92;Ninject&amp;#92;src&amp;#92;Core&amp;#92;Infrastructure&amp;#92;Debugging&amp;#92;DebugInfo.cs&amp;#58;128&lt;br /&gt;   Ninject.Core.ModuleBase&amp;#96;1.DoBind&amp;#40;Type type&amp;#41; in d&amp;#58;&amp;#92;Projects&amp;#92;Ninject&amp;#92;src&amp;#92;Core&amp;#92;Modules&amp;#92;ModuleBase.cs&amp;#58;269&lt;br /&gt;   Ninject.Core.ModuleBase&amp;#96;1.Bind&amp;#40;&amp;#41; in d&amp;#58;&amp;#92;Projects&amp;#92;Ninject&amp;#92;src&amp;#92;Core&amp;#92;Modules&amp;#92;ModuleBase.cs&amp;#58;116&lt;br /&gt;   SettingsModule.Load&amp;#40;&amp;#41; in x&amp;#58;&amp;#92;workspace&amp;#92;tour-manager&amp;#92;web&amp;#92;App_Code&amp;#92;NtmApp.cs&amp;#58;62&lt;br /&gt;   Ninject.Core.KernelBase.LoadModules&amp;#40;IEnumerable&amp;#96;1 modules&amp;#41; in d&amp;#58;&amp;#92;Projects&amp;#92;Ninject&amp;#92;src&amp;#92;Core&amp;#92;KernelBase.cs&amp;#58;358&lt;br /&gt;   Ninject.Core.KernelBase.Load&amp;#40;IModule&amp;#91;&amp;#93; modules&amp;#41; in d&amp;#58;&amp;#92;Projects&amp;#92;Ninject&amp;#92;src&amp;#92;Core&amp;#92;KernelBase.cs&amp;#58;173&lt;br /&gt;   NtmApp..cctor&amp;#40;&amp;#41; in x&amp;#58;&amp;#92;workspace&amp;#92;tour-manager&amp;#92;web&amp;#92;App_Code&amp;#92;NtmApp.cs&amp;#58;36&lt;br /&gt;&lt;br /&gt;I&amp;#39;m a novice at Ninject, so I might be missing something basic, but this seems like an internal error&amp;#63;&lt;br /&gt;</description><author>liedman</author><pubDate>Mon, 15 Feb 2010 16:29:25 GMT</pubDate><guid isPermaLink="false">Created Issue: NullReferenceException on Bind&lt;T&gt; [4038] 20100215042925P</guid></item><item><title>Created Issue: NinJect - Assembly Warning Message [3594]</title><link>http://ninject.codeplex.com/WorkItem/View.aspx?WorkItemId=3594</link><description>How can I resolve the warning message &amp;#34;Extension Attribute is defined in multiple assemblies&amp;#34; &amp;#63;&lt;br /&gt;&lt;br /&gt;Please see attached image file&lt;br /&gt;</description><author>Polar1564</author><pubDate>Sun, 20 Dec 2009 22:51:19 GMT</pubDate><guid isPermaLink="false">Created Issue: NinJect - Assembly Warning Message [3594] 20091220105119P</guid></item><item><title>Created Issue: Injected IEnumerable&lt;T&gt; instances blow up when used in LINQ queries [2948]</title><link>http://ninject.codeplex.com/WorkItem/View.aspx?WorkItemId=2948</link><description>Okay, bear with me on this one, it&amp;#39;s hard to explain clearly but I&amp;#39;ll try my best.&lt;br /&gt;&lt;br /&gt;In the following scenario&amp;#58;&lt;br /&gt;1. Multiple bindings to the same interface exist&lt;br /&gt;2. The bindings are not transient &amp;#40;they are cached somehow, whether it&amp;#39;s per-request or singleton or other&amp;#41;&lt;br /&gt;3. There are no cyclical dependencies&lt;br /&gt;4. A class is injected with an IEnumerable&amp;#60;T&amp;#62; of that type&lt;br /&gt;5. The class executes LINQ queries on that injected enumerable to, for example, separate it out into &amp;#34;categories&amp;#34; of instances&lt;br /&gt;&lt;br /&gt;Then&amp;#58; an ActivationException is thrown stating that cyclical dependencies are detected.&lt;br /&gt;&lt;br /&gt;Cause&amp;#58;&lt;br /&gt;Because Ninject uses LINQ to build up the resolved types, it is delay executed. When I execute &amp;#34;more LINQ&amp;#34; on that same list and then finally reference it, the LINQ infrastructure ends up executing the original LINQ query multiple times over the entire list. This isn&amp;#39;t bad, except that an execution path inside Ninject.Activation.Context.Resolve&amp;#40;&amp;#41; can return the resolved instance &amp;#40;if it was cached&amp;#41; without popping the requested binding off the &amp;#34;ActiveBindings&amp;#34; stack.&lt;br /&gt;It takes 3 or more &amp;#34;sub-queries&amp;#34; to make this happen because&amp;#58;&lt;br /&gt;1. First time through everything resolves correctly, instances are created and put into the cache, and the &amp;#34;ActiveBindings&amp;#34; stack is pushed&amp;#47;popped correctly.&lt;br /&gt;2. Second time through, the instances are pulled out of the cache and the ActiveBindings stack is left in a bad state &amp;#40;not popped correctly&amp;#41;, but things still return correctly.&lt;br /&gt;3. Third &amp;#40;and more&amp;#41; time through the sanity check against the &amp;#34;ActiveBindings&amp;#34; stack fails &amp;#40;because of the previous iteration&amp;#39;s bug&amp;#41; and the exception is thrown.&lt;br /&gt;&lt;br /&gt;Workaround&amp;#58;&lt;br /&gt;Instead of executing further LINQ queries on the IEnumerable&amp;#60;T&amp;#62; given to me by Ninject, I can call &amp;#34;.ToList&amp;#40;&amp;#41;&amp;#34; on it to execute the LINQ, and then do further queries on &amp;#42;that&amp;#42; list. By then, the Ninject LINQ only executes once and resolves all the types correctly only once.&lt;br /&gt;&lt;br /&gt;Possible solutions &amp;#40;need advice from those more familiar with the internals of Ninject&amp;#41;&amp;#58;&lt;br /&gt;Choice 1&amp;#58;&lt;br /&gt;In &amp;#47;Activation&amp;#47;Context.cs, the &amp;#34;public object Resolve&amp;#40;&amp;#41;&amp;#34; method could be changed from&lt;br /&gt;if &amp;#40;reference.Instance &amp;#33;&amp;#61; null&amp;#41;&lt;br /&gt;    return reference.Instance&lt;br /&gt;&lt;br /&gt;to&lt;br /&gt;&lt;br /&gt;if &amp;#40;reference.Instance &amp;#33;&amp;#61; null&amp;#41;&lt;br /&gt;&amp;#123;&lt;br /&gt;    Request.ActiveBindings.Pop&amp;#40;&amp;#41;&amp;#59;&lt;br /&gt;    return reference.Instance&amp;#59;&lt;br /&gt;&amp;#125;&lt;br /&gt;&lt;br /&gt;This would pop the binding off the &amp;#34;ActiveBindings&amp;#34; stack when it was returned from the cache, and would prevent the stack from getting into a bad state.&lt;br /&gt;Note that this solution wouldn&amp;#39;t address or fix the &amp;#34;side note&amp;#34; I have at the bottom of this report.&lt;br /&gt;&lt;br /&gt;Choice 2&amp;#58;&lt;br /&gt;Before Ninject injects the IEnumerable&amp;#60;T&amp;#62;, IList&amp;#60;T&amp;#62;, or ICollection&amp;#60;T&amp;#62;, it could &amp;#34;execute&amp;#34; the results of the LINQ query, so the incoming values to the class would be resolved at that moment and not wait until I used them within the class itself, if I did more LINQ querying on the list. It&amp;#39;s potentially &amp;#42;slightly&amp;#42; slower this way, but the net gain would be worth it, I think. Especially given that this would also resolve the &amp;#34;side note&amp;#34; below.&lt;br /&gt;&lt;br /&gt;Choice 3&amp;#58;&lt;br /&gt;Do both 1 and 2. &amp;#58;&amp;#41; This would probably clean it up the most, fixing both &amp;#34;bugs&amp;#34;.&lt;br /&gt;&lt;br /&gt;Example code for reproduction is attached. Create a new console app and use the file attached.&lt;br /&gt;&lt;br /&gt;SIDE NOTE&amp;#58;&lt;br /&gt;A side note, if I declare the bindings as transient, then this works, but only because they are never cached. Which also means that for a given input enumerable it will create a new instance of the class each time I execute a LINQ query on it. So where I would normally expect the incoming IEnumerable&amp;#60;T&amp;#62; to contain a set, it would actually create potentially many extra instances.&lt;br /&gt;</description><author>alerch</author><pubDate>Thu, 08 Oct 2009 14:42:15 GMT</pubDate><guid isPermaLink="false">Created Issue: Injected IEnumerable&lt;T&gt; instances blow up when used in LINQ queries [2948] 20091008024215P</guid></item></channel></rss>