ASP.NET MVC 2 InputExtensions在服务器上与本地计算机不同

所以这对我来说是一个疯狂的问题,但我没有运气Google搜索它。 我有一个本地运行的ASP.NET MVC 2应用程序(在.NET 4.0下)。 当我将它上传到我的生产服务器(在共享主机下)时,我得到了

编译器错误消息:CS1061:'System.Web.Mvc.HtmlHelper'不包含'TextBoxFor'的定义,并且没有找到接受'System.Web.Mvc.HtmlHelper'类型的第一个参数的扩展方法'TextBoxFor'你是否缺少using指令或程序集引用?)

对于此代码:

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

这是MVC 2中新的标准扩展方法之一。所以我写了一些诊断代码:

       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/>");
       }

本地运行(它工作正常),我得到这个作为输出:

From GAC: True
ImageRuntimeVersion: v2.0.50727
Version: File: C:WindowsassemblyGAC_MSILSystem.Web.Mvc2.0.0.0__31bf3856ad364e35System.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

并在生产服务器上运行时(它发生故障),我看到:

From GAC: True
ImageRuntimeVersion: v2.0.50727
Version: File: C:WindowsassemblyGAC_MSILSystem.Web.Mvc2.0.0.0__31bf3856ad364e35System.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
Hidden
Hidden
Hidden
Hidden
Hidden
Hidden
Password
Password
Password
Password
RadioButton
RadioButton
RadioButton
RadioButton
RadioButton
RadioButton
TextBox
TextBox
TextBox
TextBox
ToString
Equals
GetHashCode
GetType

注意“TextBoxFor”不存在(因此错误)。

我在csproj中引用了MVC:

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

根据用户Levi的建议,我上传并运行了MvcFutures的诊断页面 - 这是无辜的输出结果:

Microsoft ASP.NET MVC Diagnostics Information

This page is designed to help diagnose common errors related to mismatched or conflicting ASP.NET MVC binaries. If a known issue is identified, it will be displayed below in red text.

For questions or problems with ASP.NET MVC or this utility, please visit the ASP.NET MVC forums at http://forums.asp.net/1146.aspx.
Environment Information

Operating system: Microsoft Windows NT 6.0.6002 Service Pack 2
.NET Framework version: 4.0.30319.1 (32-bit)
Web server: Microsoft-IIS/7.0
Integrated pipeline: True
Worker process: w3wp.exe
ASP.NET MVC Assembly Information (System.Web.Mvc.dll)

Assembly version: ASP.NET MVC 2 RTM (2.0.50217.0)
Full name: System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
Code base: file:///C:/Windows/assembly/GAC_MSIL/System.Web.Mvc/2.0.0.0__31bf3856ad364e35/System.Web.Mvc.dll
Deployment: GAC-deployed
ASP.NET MVC Futures Assembly Information (Microsoft.Web.Mvc.dll)

An ASP.NET MVC Futures assembly has not been loaded into this application. If desired, you can download ASP.NET MVC 2 RTM Futures from http://go.microsoft.com/fwlink/?LinkID=183739.
All Loaded Assemblies

50 assemblies are loaded.

    * A_d509bf65_3d32_48f0_8ab6_566e289003a6, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
    * Anonymously Hosted DynamicMethods Assembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
    * App_global.asax.5qqlf9ir, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
    * App_Web_2vnklzay, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
    * App_Web_n3cjbc0f, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
    * App_Web_v3sxbd4u, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
    * DotNetPanel.IIsModules, Version=1.0.0.0, Culture=neutral, PublicKeyToken=37f9c58a0aa32ff0
    * Microsoft.Build.Framework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
    * Microsoft.Build.Utilities.v4.0, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
    * Microsoft.CSharp, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
    * Microsoft.JScript, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
    * mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
    * SMDiagnostics, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
    * System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
    * System.Activities, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
    * System.ComponentModel.DataAnnotations, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
    * System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
    * System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
    * System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
    * System.Data.DataSetExtensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
    * System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
    * System.Data.Services.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
    * System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
    * System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
    * System.EnterpriseServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
    * System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
    * System.Numerics, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
    * System.Runtime.Caching, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
    * System.Runtime.DurableInstancing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
    * System.Runtime.Serialization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
    * System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
    * System.ServiceModel.Activation, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
    * System.ServiceModel.Activities, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
    * System.ServiceModel.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
    * System.Transactions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
    * System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
    * System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
    * System.Web.ApplicationServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
    * System.Web.DynamicData, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
    * System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
    * System.Web.Mobile, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
    * System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
    * System.Web.RegularExpressions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
    * System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
    * System.Web.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
    * System.WorkflowServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
    * System.Xaml.Hosting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
    * System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
    * System.Xml.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
    * TheActivityTracker, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null

Diagnostics version: 02/16/2010 00:00:00 v7
Report generated on: 05/05/2010 18:12:56 

我无法确定下一步该做什么。 思考?

谢谢!

-麦克风


您的主机运行的是MVC 2的预发布版本(更糟糕的是,它们似乎已经GAC了它!)它们也可能正在运行.NET 4 Framework的预发布版本。

打电话给他们,告诉他们升级到RTM版本。 :)


尝试删除提示路径和特定版本

<Reference 
Include="System.Web.Mvc, Version=2.0.0.0, 
Culture=neutral, 
PublicKeyToken=31bf3856ad364e35, 
processorArchitecture=MSIL" />
链接地址: http://www.djcxy.com/p/64285.html

上一篇: ASP.NET MVC 2 InputExtensions different on server than local machine

下一篇: Set FileList of FileInput in Firefox