代码之家  ›  专栏  ›  技术社区  ›  Zack Peterson

无法加载文件或程序集“System”。网状物。Mvc'

  •  205
  • Zack Peterson  · 技术社区  · 16 年前

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


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


    配置错误

    说明: 处理此请求所需的配置文件时出错。请查看下面的具体错误详细信息,并适当修改您的配置文件。

    分析器错误消息: 无法加载文件或程序集“System”。网状物。多视图控制,版本=1.0.0.0,区域性=中性,公钥令牌=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

    装配负载跟踪: 以下信息有助于确定组件“系统”的原因。网状物。无法加载Mvc,版本=1.0.0.0,区域性=中性,公钥令牌=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].
    

    版本信息: 微软。NET框架版本:2.0.50727.3053;ASP。NET版本:2.0.50727.3053


    我需要安装 AspNetMVCBeta-setup.msi 在服务器上?或者服务器有不同的安装程序吗?

    enter image description here

    19 回复  |  直到 16 年前
        1
  •  213
  •   Community CDub    8 年前

    我刚刚写了一篇博客来解决这个问题。你可以安装ASP。NET MVC在您的服务器上,或者您可以遵循 steps here .


    编辑: (由jcolebrand提供)我浏览了这个链接,然后遇到了与 Victor below ,所以我建议你也加上这些:

    * Microsoft.Web.Infrastructure
    * System.Web.Razor
    * System.Web.WebPages.Deployment
    * System.Web.WebPages.Razor
    
        2
  •  41
  •   Victor Juri    14 年前

    我遇到了与sgriffinusa相同的问题。 除了参考文献,菲尔的文章还建议: http://www.haacked.com/archive/2008/11/03/bin-deploy-aspnetmvc.aspx 。我添加了以下内容:

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

    Godaddy部署工作得很好。关闭自定义错误并添加引用以更正错误。这应该会让你朝着正确的方向前进。

        3
  •  26
  •   Matt Rudder    16 年前

    直接在web服务器上安装MVC是一种选择,因为这样程序集将安装在GAC中。您还可以对程序集进行bin部署,这可能有助于在最终版本可用之前,让您的服务器远离预发布程序集。

    Phil Haack几天前发布了一篇关于如何将MVC与你的应用程序一起部署的好文章,所以没有必要直接安装:

    http://www.haacked.com/archive/2008/11/03/bin-deploy-aspnetmvc.aspx

        4
  •  25
  •   sgriffinusa    14 年前

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

    基本上,除了@Haacked的帖子中列出的引用外,您还需要添加对以下内容的引用,并将其设置为按所述在本地部署。

    • 微软。网状物。基础设施
    • 系统。网状物。剃刀
    • 系统。网状物。网页。部署
    • 系统。网状物。网页。剃刀
        5
  •  13
  •   warrickh    13 年前

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

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

        6
  •  9
  •   Axle    13 年前

    Quick&;简单解决方案: 我在微软遇到了这个问题。AspNet。Mvc版本5.2.3,在经历了所有这些线程之后,我找到了一个最简单的解决方案。

    只需按照以下步骤操作:

    1. 在Visual studio中为您的项目打开NuGet包管理器
    2. 搜索Microsoft。AspNet。MVC模式
    3. 找到后,将操作更改为卸载并卸载它
    4. 完成后,重新安装并立即尝试

    这将自动修复引用的所有问题。 见下图:

    enter image description here

        7
  •  6
  •   chris    12 年前

    简单的修复。在VS2010中,右键单击您的MVC项目,选择“添加可部署依赖项…”,选择所需的选项,然后单击“确定”

        8
  •  6
  •   Romeo    10 年前

    有同样的问题,并添加了他们所说的所有程序集,但仍然出现了同样的错误。

    事实证明,你需要“ 特定版本 错误的

    Specific version should be false.

        9
  •  6
  •   Moumit    9 年前

    我们想添加它,因为我们正在创建一个使用它的类库。

    对我来说,它就在这里。..

    C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET MVC 4\Assemblies

        10
  •  3
  •   Community CDub    8 年前

    如果您没有使用托管服务提供商,并且可以访问服务器进行安装。..然后安装MVC 3更新工具,这样做。..它将为您在windows 2003服务器/ISI6计算机上节省数小时的问题。,我在这里评论了这个页面 Nuget.Core.dll version number mismatch

        11
  •  3
  •   James Lawruk    14 年前

    除了哈克的职位,汉塞尔曼也有类似的职位。 BIN Delploying ASP.NET MVC 3 with Razor to a Windows Server without MVC installed

    对我来说,“Copy Local=true”解决方案是不够的,因为我的网站的项目引用没有包括所有缺失的dll。正如Scott在他的帖子中提到的,我还需要从开发箱上的以下文件夹中获取额外的dll:C:\Program Files(x86)\Microsoft ASP。NET\ASP。NET网页\v1.0\程序集。错误消息告诉我缺少了哪个dll(System.Seb.Infrastructure、System.Seb.RRazor等)。我继续逐一添加每个缺少的dll,直到它工作为止。

        12
  •  3
  •   Olaj    9 年前

    我在Visual Studio 2015中做了一个“更新包重新安装Microsoft.AspNet.Mvc”来修复它。

        13
  •  2
  •   Dave    10 年前

    一个重要的考虑因素是web.config文件,一些包可能会破坏你的绑定重定向,造成严重破坏(流氓包是我没有从包中删除web.config的内部包,或者确保包中的web.config没有任何绑定重定向。例如,通过删除重复和不正确的节点可以解决这个问题

        <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行来修复构建。

        14
  •  2
  •   tugberk    10 年前

    还要检查您的web.config中的程序集版本 视图文件夹 并确保它匹配。我有时会忘记在那个位置有第二个web.config。

        15
  •  2
  •   fredmaggiowski Alex    9 年前

    在将项目转移到另一个解决方案后,我对一堆程序集文件也遇到了同样的问题。

    对我来说 web.config 文件试图添加此程序集:

    <add assembly="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    

    以为项目中的引用指向版本 3.0.0.0 (单击引用并滚动到属性底部)。因此,我只是更改了参考版本 web.config文件 文件。

    我不知道这是否只是某种错误。添加所有其他引用的问题是,引用出现在配置文件中,但实际上根本没有在项目中引用(在解决方案资源管理器中),所需的文件也没有与其他项目文件一起复制,可能是因为没有被复制 "copy local = true"

    现在,我无法在可添加程序集中找到这些程序集(通过右键单击引用并尝试从程序集或扩展中添加它们)。相反,我创建了一个新的MVC解决方案,添加了我需要的所有程序集和引用,并在解决方案资源管理器中的新项目引用下找到它们,在引用的属性窗口中找到它们的路径。

    然后,我只是将所需的库复制到另一个项目中并引用它们。

        16
  •  0
  •   Matan L    12 年前

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

        17
  •  0
  •   Jenzo    12 年前

    我在.net项目中使用Jenkins,在MVC 4引用方面遇到了问题。

    我最终通过使用解决了我的问题。基于注册表的网络参考搜索引擎功能,使用:

    “HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft.NETFramework\v2.0.50727\AssemblyFoldersEx”

    例如,您可以创建子项并将默认密钥设置为“c:\myreferenceeedir”。

    它用MVC版本和ASP.net网页拯救了我。

    在“添加引用对话框”中添加引用是有用的

    http://dhakshinamoorthy.wordpress.com/2011/12/04/how-to-register-your-net-assembly-in-gac-and-make-it-show-in-add-reference-dialog/

        18
  •  0
  •   actual_kangaroo    10 年前

    正如其他人所提到的,将这些引用添加到视觉工作室中 Copy Local 吃起来 true (我还得补充一下 System.Web.Webpages )

    Microsoft.Web.Infrastructure
    System.Web.Razor
    System.Web.WebPages.Deployment
    System.Web.WebPages.Razor
    System.Web.Webpages
    
        19
  •  0
  •   Brian Rice    9 年前

    我使用管理NuGet包添加了“Microsoft ASP.NET Razor”。

    由于某种原因,在添加引用时,我只有系统。网状物。辅助工具1.0.0和2.0.0…但不是3.0.0。

    另一个可行的选择是删除对系统的引用。网状物。Mvc和系统。网状物。Http。..然后将它们重新添加到csproj文件中的包位置(您可以使用文本编辑器轻松编辑项目):

    <Reference Include="System.Web.Http">
      <HintPath>..\packages\Microsoft.AspNet.WebApi.Core.5.2.3\lib\net45\System.Web.Http.dll</HintPath>
    
    <Reference Include="System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
      <HintPath>..\packages\Microsoft.AspNet.Mvc.5.2.3\lib\net45\System.Web.Mvc.dll</HintPath>
    
        20
  •  0
  •   PBo    8 年前