我的新ASP。NET MVC Web应用程序工作在我的开发工作站,但不运行在我的Web服务器…


“/”应用程序中的服务器错误。


配置错误

描述:在处理服务此请求所需的配置文件期间发生了错误。请检查下面的特定错误详细信息,并适当修改配置文件。

解析器错误信息:无法加载文件或程序集System.Web。Mvc,版本=1.0.0.0,文化=中性,PublicKeyToken=31bf3856ad364e35'或其依赖项之一。系统无法找到指定的文件。

源错误:

Line 44:         <add assembly="System.Web.Abstractions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
Line 45:         <add assembly="System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
Line 46:         <add assembly="System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
Line 47:         <add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
Line 48:         <add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>

来源文件:C:\inetpub\www.example.org\web.config行:46

程序集加载跟踪:以下信息有助于确定程序集的“System.Web. exe”为何为“System.Web. exe”。Mvc,版本=1.0.0.0,文化=中性,PublicKeyToken=31bf3856ad364e35'无法加载。

WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

版本信息:Microsoft .NET Framework版本:2.0.50727.3053;ASP。净版:2.0.50727.3053


我是否需要安装aspnetmvcbeta安装程序?服务器上的Msi ?或者服务器有不同的安装程序?


当前回答

除了Haack的帖子,Hanselman也有类似的帖子。BIN部署ASP。NET MVC 3与Razor到Windows服务器没有安装MVC

For me, the "Copy Local = true" solution was insufficient because my Website's project references did not include all the dlls that were missing. As Scott mentions in his post, I also needed to get additional dlls from the following folder on my development box: C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\Assemblies. The error message informed me which dll was missing (System.Web.Infrastructure, System.Web.Razor, etc.) I continued to add each missing dll, one by one, until it worked.

其他回答

我在GoDaddy共享主机上部署我的MVC3 Razor web应用程序时遇到了同样的问题。还有一些额外的.dll需要被引用。详情:http://paulmason.biz/?p=108

基本上,除了@ haacks的帖子中列出的引用外,您还需要添加以下引用,并将它们设置为在本地部署。

Microsoft.Web.Infrastructure System.Web.Razor System.Web.WebPages.Deployment System.Web.WebPages.Razor

在VS2010中,在解决方案资源管理器中右键单击项目并选择“添加可部署依赖项”。然后勾选下面对话框中与MVC相关的复选框。

这将在项目中创建一个'_bin_deployableAssemblies'文件夹,其中包含其他答案中提到的所有.dll文件。我相信在创建部署包时,会将这些文件复制到bin文件夹中。

还要在web上检查程序集的版本。在你的Views文件夹中,并确保它匹配。我有时会忘记还有第二个网络。在该位置配置。

在尝试了所有方法但仍然失败之后,这便是我的解决方法: 我记得我上次在我的Visual studio中更新MVC版本时出错了,所以我从另一个Visual studio(不同的计算机)运行项目,然后上传dll-s,它工作了。 也许它会帮助到某人……

一个重要的考虑是网络。配置文件,一些包可以破坏你的绑定重定向造成严重破坏(流氓包是在内部包,我没有删除网页。配置从包或确保网络。配置在包中没有任何绑定重定向。例如,通过删除重复和不正确的节点来解决这个问题

    <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
            <dependentAssembly>
                <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31BF3856AD364E35" culture="neutral"/>
                <bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0"/>
            </dependentAssembly>
            <dependentAssembly>


                <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35"/>
                <bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0"/>
                <assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
                <bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0"/>
                <assemblyIdentity name="Microsoft.Owin.Security.OAuth" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
                <assemblyIdentity name="Microsoft.Owin.Security" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
                <assemblyIdentity name="Microsoft.Owin.Security.Cookies" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
                <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral"/>
                <bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0"/>
                <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
                <bindingRedirect oldVersion="0.0.0.0-1.6.5135.21930" newVersion="1.6.5135.21930"/>
                <assemblyIdentity name="Antlr3.Runtime" publicKeyToken="eb42632606e9261f" culture="neutral"/>
                <bindingRedirect oldVersion="0.0.0.0-3.5.0.2" newVersion="3.5.0.2"/>


                <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35"/>
                <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0"/>
            </dependentAssembly>
            <dependentAssembly>
                <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35"/>
                <bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0"/>
            </dependentAssembly>
            <dependentAssembly>
                <assemblyIdentity name="Microsoft.Owin.Security" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
                <bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0"/>
            </dependentAssembly>
            <dependentAssembly>
                <assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
                <bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0"/>
            </dependentAssembly>
            <dependentAssembly>
                <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral"/>
                <bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0"/>
            </dependentAssembly>
            <dependentAssembly>
                <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
                <bindingRedirect oldVersion="0.0.0.0-1.6.5135.21930" newVersion="1.6.5135.21930"/>
            </dependentAssembly>
            <dependentAssembly>
                <assemblyIdentity name="Microsoft.Owin.Security.Cookies" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
                <bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0"/>
            </dependentAssembly>
            <dependentAssembly>
                <assemblyIdentity name="Microsoft.Owin.Security.OAuth" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
                <bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0"/>
            </dependentAssembly>
            <dependentAssembly>
                <assemblyIdentity name="SimpleInjector" publicKeyToken="984cb50dea722e99" culture="neutral"/>
                <bindingRedirect oldVersion="0.0.0.0-3.3.2.0" newVersion="3.3.2.0"/>
            </dependentAssembly>
            <dependentAssembly>
                <assemblyIdentity name="Antlr3.Runtime" publicKeyToken="eb42632606e9261f" culture="neutral"/>
                <bindingRedirect oldVersion="0.0.0.0-3.5.0.2" newVersion="3.5.0.2"/>
            </dependentAssembly>
            <dependentAssembly>
                <assemblyIdentity name="HtmlAgilityPack" publicKeyToken="bd319b19eaf3b43a" culture="neutral"/>
                <bindingRedirect oldVersion="0.0.0.0-1.4.9.5" newVersion="1.4.9.5"/>
            </dependentAssembly>
        </assemblyBinding>
    </runtime>

通过删除第8行到第24行修复构建。