title: Why can I not call the DropDownList extensions methods from another extension method?
body: <p>This extension method does not work on two separate development machines:</p>
  
  <pre><code>public static string DdlTest(this HtmlHelper helper)
  {
      var si = new List&lt;SelectListItem&gt;();
      si.Add(new SelectListItem() { Text = "1", Value = "1" });
      si.Add(new SelectListItem() { Text = "2", Value = "2" });
      return helper.DropDownList("test", si, new { Class = "Hey" });
  }
  </code></pre>
  
  <p>I get the following error:</p>
  
  <blockquote>
    <p>Method not found: 'System.String System.Web.Mvc.Html.SelectExtensions.DropDownList(System.Web.Mvc.HtmlHelper, System.String, System.Collections.Generic.IEnumerable`1, System.Object)'.</p>
  </blockquote>
  
  <p>However, this <em>in-line</em> code <strong>does work</strong>:</p>
  
  <pre><code>&lt;%
      var si = new List&lt;SelectListItem&gt;();
      si.Add(new SelectListItem() { Text = "1", Value = "1" });
      si.Add(new SelectListItem() { Text = "2", Value = "2" });
  %&gt;
  &lt;%= Html.DropDownList("test", si, new { Class = "Hey" })%&gt;
  </code></pre>
  
  <p>Could someone please verify I'm not going crazy!</p>
  
  <h2>Please be aware:</h2>
  
  <p>It <strong>does</strong> work in VS2010 and .NET 4 beta 2.</p>
  
  <p>It <strong>does</strong> work in VS2010 with MVC 2 beta.</p>
  
  <p>It <strong>does not</strong> work in VS2008 with MVC 1!!</p>
  
  <p>On <strong>both</strong> machines I have VS2010 beta 2 and VS2008 installed side-by-side.</p>
  
  <p>Am I doing something wrong here?</p>
  
  <p><b>Edit:</b></p>
  
  <p>For now I've hacked this by disassembling the SelectExtensions class and implementing it myself, which works. Interestingly, in the disassembled code there was an ambiguous method call error.. not sure if this is just the result of reflection though.</p>
  
  <p><b>Edit 2:</b></p>
  
  <p>To make the example clearer, suppose this ASPX:</p>
  
  <pre><code>&lt;%
      var si = new List&lt;SelectListItem&gt;();
      si.Add(new SelectListItem() { Text = "1", Value = "1" });
      si.Add(new SelectListItem() { Text = "2", Value = "2" });
  %&gt;
  &lt;%= Html.DropDownList("test", si, new { Class = "Hey" })%&gt;
  &lt;%= Html.TextBox("testing")%&gt;
  &lt;%= Html.DdlTest1("test", si, new { Class = "Hey" })%&gt;
  &lt;%= Html.DdlTest2("test", si, new { Class = "Hey" })%&gt;
  &lt;%= Html.Test3()%&gt;
  </code></pre>
  
  <p>And this in my extension methods class:</p>
  
  <pre><code>using System.Web.Mvc;
  using System.Web.Mvc.Html;
  
  ...
  
  public static string DdlTest1(this HtmlHelper helper, string name,
      IEnumerable&lt;SelectListItem&gt; items, object htmlAttributes)
  {
      return "Whatever";
  }
  
  public static string DdlTest2(this HtmlHelper helper, string name,
      IEnumerable&lt;SelectListItem&gt; items, object htmlAttributes)
  {
      return helper.DropDownList(name, items, htmlAttributes);
  }
  
  public static string Test3(this HtmlHelper helper)
  {
      return helper.TextBox("testing");
  }
  </code></pre>
  
  <p><code>&lt;%= Html.DropDownList("test", si, new { Class = "Hey" })%&gt;</code> will work<br>
  <code>&lt;%= Html.TextBox("testBox")%&gt;</code> will work
  <code>&lt;%= Html.DdlTest1() %&gt;</code> will work<br>
  <code>&lt;%= Html.DdlTest2() %&gt;</code> will give the following error:</p>
  
  <blockquote>
    <p>Method not found: 'System.String System.Web.Mvc.Html.SelectExtensions.DropDownList(System.Web.Mvc.HtmlHelper, System.String, System.Collections.Generic.IEnumerable`1, System.Object)'.</p>
  </blockquote>
  
  <p><code>&lt;%= Html.DdlTest3() %&gt;</code> will give the following error:</p>
  
  <blockquote>
    <p>Method not found: 'System.String System.Web.Mvc.Html.InputExtensions.TextBox(System.Web.Mvc.HtmlHelper, System.String)'.</p>
  </blockquote>
  
  <p>So we can conclude that the ASPX can find <em>my</em> extension methods, and even the normal .NET ones. But when <em>my</em> extensions, in MVC 1, try to call the standard extensions, trouble brews!</p>
  
  <h2>Edit 3:</h2>
  
  <p>Sigh.</p>
  
  <p>I found the problem, and I suppose in many ways Aaronaught buddy you were right!</p>
  
  <p>I <strong>did</strong> have the assembly reference in my Web.Config, but I'd missed one tiny detail:</p>
  
  <blockquote>
    <p>&lt;add assembly="System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/&gt;</p>
  </blockquote>
  
  <p>It really should have read:</p>
  
  <blockquote>
    <p>&lt;add assembly="System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/&gt;</p>
  </blockquote>
  
  <p>I didn't spot that evil, b*stard <strong><em>2</em></strong> in there. I'm sorry peeps, thanks for all your help. Points go to you Aaronaught as you were right after all!</p>