ASP.NET MVC 2 InputExtensions different on server than local machine

Posted by Mike on Stack Overflow See other posts from Stack Overflow or by Mike
Published on 2010-05-04T01:32:14Z Indexed on 2010/05/04 1:38 UTC
Read the original article Hit count: 811

Filed under:

Hi everyone,

So this is kind of a crazy problem to me, but I've had no luck Googling it. I have an ASP.NET MVC 2 application (under .NET 4.0) running locally just fine. When I upload it to my production server (under shared hosting) I get

Compiler Error Message: CS1061: 'System.Web.Mvc.HtmlHelper' does not contain a definition for 'TextBoxFor' and no extension method 'TextBoxFor' accepting a first argument of type 'System.Web.Mvc.HtmlHelper' could be found (are you missing a using directive or an assembly reference?)

for this code:

<%= this.Html.TextBoxFor(person => person.LastName) %>

This is one of the new standard extension methods in MVC 2. So I wrote some diagnostic code:

       System.Reflection.Assembly ass = System.Reflection.Assembly.GetAssembly(typeof(InputExtensions));

       Response.Write("From GAC: " + ass.GlobalAssemblyCache.ToString() + "<br/>");
       Response.Write("ImageRuntimeVersion: " + ass.ImageRuntimeVersion.ToString() + "<br/>");
       Response.Write("Version: " + System.Diagnostics.FileVersionInfo.GetVersionInfo(ass.Location).ToString() + "<br/>");

       foreach (var method in typeof(InputExtensions).GetMethods())
       {
           Response.Write(method.Name + "<br/>");
       }

running locally (where it works fine), I get this as output:

From GAC: True
ImageRuntimeVersion: v2.0.50727
Version: File: C:\Windows\assembly\GAC_MSIL\System.Web.Mvc\2.0.0.0__31bf3856ad364e35\System.Web.Mvc.dll InternalName: System.Web.Mvc.dll OriginalFilename: System.Web.Mvc.dll FileVersion: 2.0.50217.0 FileDescription: System.Web.Mvc.dll Product: Microsoft® .NET Framework ProductVersion: 2.0.50217.0 Debug: False Patched: False PreRelease: False PrivateBuild: False SpecialBuild: False Language: Language Neutral
CheckBox
CheckBox
CheckBox
CheckBox
CheckBox
CheckBox
CheckBoxFor
CheckBoxFor
CheckBoxFor
Hidden
Hidden
Hidden
Hidden
HiddenFor
HiddenFor
HiddenFor
Password
Password
Password
Password
PasswordFor
PasswordFor
PasswordFor
RadioButton
RadioButton
RadioButton
RadioButton
RadioButton
RadioButton
RadioButtonFor
RadioButtonFor
RadioButtonFor
TextBox
TextBox
TextBox
TextBox
TextBoxFor
TextBoxFor
TextBoxFor
ToString
Equals
GetHashCode
GetType

and when running on the production server (where it fails), I see:

From GAC: True
ImageRuntimeVersion: v2.0.50727
Version: File: C:\Windows\assembly\GAC_MSIL\System.Web.Mvc\2.0.0.0__31bf3856ad364e35\System.Web.Mvc.dll InternalName: System.Web.Mvc.dll OriginalFilename: System.Web.Mvc.dll FileVersion: 2.0.41001.0 FileDescription: System.Web.Mvc.dll Product: Microsoft® .NET Framework ProductVersion: 2.0.41001.0 Debug: False Patched: False PreRelease: False PrivateBuild: False SpecialBuild: False Language: Language Neutral
CheckBox
CheckBox
CheckBox
CheckBox
CheckBox
CheckBox
Hidden
Hidden
Hidden
Hidden
Hidden
Hidden
Password
Password
Password
Password
RadioButton
RadioButton
RadioButton
RadioButton
RadioButton
RadioButton
TextBox
TextBox
TextBox
TextBox
ToString
Equals
GetHashCode
GetType

note that "TextBoxFor" is not present (hence the error).

I have MVC referenced in the csproj:

<Reference Include="System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
  <SpecificVersion>True</SpecificVersion>
  <HintPath>References\System.Web.Mvc.dll</HintPath>
  <Private>True</Private>
</Reference>

I just can't figure it what to do next. Thoughts?

Thanks!

-Mike

© Stack Overflow or respective owner

Related posts about asp.net-mvc