简体   繁体   English

System.web.mvc 丢失

[英]System.web.mvc missing

We have an old ASP.NET MVC 3 Web Application, building in VS2010, that fails to compile, since last week's security update.自上周的安全更新以来,我们有一个在 VS2010 中构建的旧 ASP.NET MVC 3 Web 应用程序,该应用程序无法编译。

The problem is that the reference to System.Web.Mvc.dll is broken.问题是对 System.Web.Mvc.dll 的引用已损坏。

When I open the solution file on our build machine, where the security update has not run, and open the properties dialog for References->System.Web.MVC, it looks just fine.当我在未运行安全更新的构建机器上打开解决方案文件并打开 References->System.Web.MVC 的属性对话框时,它看起来很好。

Path is C:\\Program Files\\Microsoft ASP.NET\\ASP.NET MVC 3\\Assemblies\\System.Web.Mvc.dll Version is 3.0.0.0路径是 C:\\Program Files\\Microsoft ASP.NET\\ASP.NET MVC 3\\Assemblies\\System.Web.Mvc.dll 版本是 3.0.0.0

But when I open the solution file on a dev machine where the security update has run, References->System.Web.MVC is flagged as missing.但是当我在运行安全更新的开发机器上打开解决方案文件时,References->System.Web.MVC 被标记为丢失。 If I remove it, and try to add it back using VS2010's Add Reference dialog, it doesn't show.如果我删除它,并尝试使用 VS2010 的“添加引用”对话框将其添加回来,它不会显示。

Wandering around the web has led me to suggestions involving updating MVC using NuGet.在网上闲逛让我建议使用 NuGet 更新 MVC。 We didn't use NuGet, in our VS2010 projects, so that doesn't seem quite right, for this situation.我们在 VS2010 项目中没有使用 NuGet,因此对于这种情况,这似乎不太正确。 I tried it anyway, and ended up with half-a-dozen missing references.无论如何,我尝试了它,最终丢失了六个参考文献。

When I look at the properties for "C:\\Program Files\\Microsoft ASP.NET\\ASP.NET MVC 3\\Assemblies\\System.Web.Mvc.dll" in Windows Explorer, on the build machine I see version 3.0.0.0.当我在 Windows 资源管理器中查看“C:\\Program Files\\Microsoft ASP.NET\\ASP.NET MVC 3\\Assemblies\\System.Web.Mvc.dll”的属性时,在构建机器上我看到了 3.0.0.0 版。

When I look at the properties on the dev machine, I see version 3.0.50813.1.当我查看开发机器上的属性时,我看到版本 3.0.50813.1。

What I need is a way to change the way I build and run so that I can build and run regardless of which of these two DLLs in installed in the .NET 3.0 framework.我需要的是一种改变我构建和运行方式的方法,这样无论.NET 3.0 框架中安装了这两个DLL 中的哪一个,我都可以构建和运行。

Ideas?想法?

What I have tried that didn't work我尝试过的方法没有用

First attempt - if the assembly is missing, add it.第一次尝试 - 如果缺少程序集,请添加它。 I deleted the old missing reference.我删除了旧的缺失参考。 Then I copied the DLL from the "ASP.NET MVC3\\Assemblies" folder, into a folder in my project.然后我将 DLL 从“ASP.NET MVC3\\Assemblies”文件夹复制到我项目中的一个文件夹中。 Set it as "Copy Always", and added it as a reference.将其设置为“始终复制”,并将其添加为参考。

With that, the project would compile in VS2010, but when I'd try to precompile the pages with aspnet_compiler, I got warnings:这样,该项目将在 VS2010 中编译,但是当我尝试使用 aspnet_compiler 预编译页面时,我收到警告:

(0): warning CS1702: Assuming assembly reference 'System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' matches 'System.Web.Mvc, Version=3.0.0.1, Culture=neutral, PublicKeyToken=31bf3856ad364e35', you may need to supply runtime policy

So far, I've been able to manage to avoid understanding runtime policies, but I tried to add this, in the web.config:到目前为止,我已经能够设法避免理解运行时策略,但我尝试在 web.config 中添加它:

<runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
        <dependentAssembly>
            <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
            <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.1" />
        </dependentAssembly>
    </assemblyBinding>
</runtime>

Tried it again, and got the same warnings.再次尝试,并得到相同的警告。

My question is - do I still have a problem?我的问题是 - 我还有问题吗? Or will my resolve it, despite the warnings?还是我会解决它,尽管有警告?

Get the latest version of MVC3 via NuGet.通过 NuGet 获取最新版本的 MVC3。 Open your project in Dev Studio.在 Dev Studio 中打开您的项目。 Open the Package Manager Console tab at the bottom of Dev Studio.打开 Dev Studio 底部的 Package Manager Console 选项卡。 Then use this command:然后使用这个命令:

PM> Install-Package Microsoft.AspNet.Mvc -Version 3.0.50813.1

If you click the tab key after "-Version" you will get a list of all of the available versions.如果单击“-Version”后的 Tab 键,您将获得所有可用版本的列表。

If you have an old version of NuGet you may get an error indicating you have to upgrade it.如果您使用的是旧版本的 NuGet,您可能会收到一条错误消息,指示您必须升级它。 If so, open Tools->Extension Manager to install the latest version of NuGet.如果是这样,打开工具->扩展管理器安装最新版本的 NuGet。 Note, you will need to run Dev Studio as Administrator before you can install NuGet.请注意,您需要以管理员身份运行 Dev Studio,然后才能安装 NuGet。

Installing MVC3 should update Web.config in your project.安装 MVC3 应更新项目中的 Web.config。

<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
  <dependentAssembly>
    <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
    <bindingRedirect oldVersion="0.0.0.0-3.0.0.1" newVersion="3.0.0.1" />
  </dependentAssembly>
</assemblyBinding>

MVC 5 MVC 5

C:\\Program Files (x86)\\Microsoft ASP.NET\\ASP.NET Web Stack 5\\Packages\\ Microsoft.AspNet.Mvc.5.0.0\\lib\\net45\\System.Web.Mvc.dll C:\\Program Files (x86)\\Microsoft ASP.NET\\ASP.NET Web Stack 5\\Packages\\Microsoft.AspNet.Mvc.5.0.0\\lib\\net45\\System.Web.Mvc.dll

MVC 4 MVC 4

C:\\Program Files (x86)\\Microsoft ASP.NET\\ASP.NET MVC 4\\Assemblies\\System.Web.Mvc.dll C:\\Program Files (x86)\\Microsoft ASP.NET\\ASP.NET MVC 4\\Assemblies\\System.Web.Mvc.dll

MVC 3 MVC 3

C:\\Program Files (x86)\\Microsoft ASP.NET\\ASP.NET MVC 3\\Assemblies\\System.Web.Mvc.dll C:\\Program Files (x86)\\Microsoft ASP.NET\\ASP.NET MVC 3\\Assemblies\\System.Web.Mvc.dll

MVC 2 MVC 2

C:\\Program Files (x86)\\Microsoft ASP.NET\\ASP.NET MVC 2\\Assemblies\\System.Web.Mvc.dll C:\\Program Files (x86)\\Microsoft ASP.NET\\ASP.NET MVC 2\\Assemblies\\System.Web.Mvc.dll

Where can I find System.Web.MVC dll in a system where MVC 3 is installed? 在安装了 MVC 3 的系统中,在哪里可以找到 System.Web.MVC dll?

Easiest way to solve this problem is install ASP.NET MVC 3 from Web Platforms installer.解决此问题的最简单方法是从 Web 平台安装程序安装 ASP.NET MVC 3。

在此处输入图片说明

http://www.microsoft.com/web/downloads/ http://www.microsoft.com/web/downloads/

Or by using Nuget command或者使用 Nuget 命令

Install-Package Microsoft.AspNet.Mvc -Version 3.0.50813.1

在 VS 2017 中,我清理了解决方案并重建了它并修复了它

I have the same situation: Visual Studio 2010, no NuGet installed, and an ASP.NET application using System.Web.Mvc version 3.我有同样的情况:Visual Studio 2010,未安装 NuGet,以及使用 System.Web.Mvc 版本 3 的 ASP.NET 应用程序。

What worked for me, was to set each C# project that uses System.Web.Mvc, to go to References in the Solution Explorer, and set properties on System.Web.Mvc, with Copy Local to true, and Specific Version to false - the last one caused the Version field to show the current version on that machine.对我有用的是设置每个使用 System.Web.Mvc 的 C# 项目,转到解决方案资源管理器中的引用,并在 System.Web.Mvc 上设置属性,复制本地为 true,特定版本为 false -最后一个导致版本字段显示该机器上的当前版本。

Just in case someone is a position where he get's the same error.以防万一有人是他得到同样错误的位置。 In my case downgrading Microsoft.AspNet.Mvc and then upgrading it again helped.在我的情况下,降级 Microsoft.AspNet.Mvc 然后再次升级它有帮助。 I had this problem after installing Glimpse and removing it.安装 Glimpse 并将其删除后,我遇到了这个问题。 System.Web.Mvc was references wrong somehow, cleaning the solution or rebuilding it didin't worked in my case. System.Web.Mvc 以某种方式引用错误,清理解决方案或重建它在我的情况下不起作用。 Just give it try if none of the above answers works for you.如果以上答案都不适合您,请尝试一下。

Had this problem in vs2017, I already got MVC via nuget but System.Web.Mvc didn't appear in the "Assemblies" list under "Add Reference".在 vs2017 中有这个问题,我已经通过 nuget 获得了 MVC,但是 System.Web.Mvc 没有出现在“添加引用”下的“程序集”列表中。

The solution was to select "Extensions" under "Assemblies" in the "Add Reference" dialog.解决方案是在“添加引用”对话框中的“程序集”下选择“扩展”。

In my case I had all of the proper references in my project.就我而言,我的项目中有所有正确的引用。 I found that by building the solution the nuget packages were automatically restored.我发现通过构建解决方案,nuget 包会自动恢复。

The sample mvcmusicstore.codeplex.com opened in vs2015 missed some references, one of them System.web.mvc.在 vs2015 中打开的示例 mvcmusicstore.codeplex.com 遗漏了一些引用,其中之一是 System.web.mvc。

The fix for this was to remove it from the references and to add a reference: choose Extentions under Assemblies, there you can find and add System.Web.Mvc.对此的修复是从引用中删除它并添加一个引用:在程序集下选择扩展,您可以在那里找到并添加 System.Web.Mvc。

(The other assemblies I added with the nuget packages.) (我用 nuget 包添加的其他程序集。)

从 ./packages/Microsoft.AspNet.Mvc.[version]/lib/net45/System.Web.Mvc.dll 再次添加引用

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM