System.web.mvc 丢失

我们有一个旧的 ASP.NET MVC 3 Web 应用程序,构建在 VS2010中,自从上周的安全更新以来无法编译。

问题是对 System.Web.Mvc.dll 的引用中断了。

当我在生成机器上打开解决方案文件(安全更新尚未运行)并打开 References-> System 的属性对话框时。Web.MVC,看起来没问题。

路径是 C: Program Files Microsoft ASP.NET ASP.NET MVC 3 Assembly System. Web.MVC.dll 版本是3.0.0.0

但是,当我在运行安全更新的开发计算机上打开解决方案文件时,References-> System。Web.MVC 被标记为失踪。如果我删除它,并尝试使用 VS2010的添加引用对话框重新添加它,它不会显示。

在网上闲逛让我想到了一些建议,包括使用 NuGet 更新 MVC。在我们的 VS2010项目中,我们没有使用 NuGet,所以在这种情况下,这似乎不太合适。我还是试了,结果少了半打推荐信。

当我查看“ C: Program Files Microsoft ASP.NET ASP.NET MVC 3 Assembly System”的属性时。韦伯。Mvc.dll”的文件资源管理器,在 build 机器上我看到了3.0.0.0版本。

当我查看 dev 机器上的属性时,我看到版本3.0.50813.1。

我需要的是一种更改生成和运行方式的方法,这样无论这两个 DLL 中的哪一个安装在。NET 3.0框架。

有什么想法吗?

我所做的努力没有奏效

第一次尝试-如果程序集丢失,则添加它。我删除了以前丢失的引用。然后,我将 DLL 从“ ASP.NET MVC3 Assembly”文件夹复制到项目中的一个文件夹中。将其设置为“始终复制”,并将其添加为参考。

这样,项目就可以在 VS2010中编译了,但是当我尝试用 aspnet _ Editor 预编译页面时,我收到了警告:

(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

到目前为止,我已经能够设法避免理解运行时策略,但我试图在 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>

再试一次,得到了同样的警告。

我的问题是——我还有问题吗? 或者我会不顾警告解决它吗?

247182 次浏览

Get the latest version of MVC3 via NuGet. Open your project in Dev Studio. Open the Package Manager Console tab at the bottom of Dev Studio. 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.

If you have an old version of NuGet you may get an error indicating you have to upgrade it. If so, open Tools->Extension Manager to install the latest version of NuGet. Note, you will need to run Dev Studio as Administrator before you can install NuGet.

Installing MVC3 should update Web.config in your project.

<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>

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.

I have the same situation: Visual Studio 2010, no NuGet installed, and an ASP.NET application using System.Web.Mvc version 3.

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.

The sample mvcmusicstore.codeplex.com opened in vs2015 missed some references, one of them 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.

(The other assemblies I added with the nuget packages.)

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

MVC 4

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

MVC 3

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

MVC 2

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?

Easiest way to solve this problem is install ASP.NET MVC 3 from Web Platforms installer.

enter image description here

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

Or by using Nuget command

Install-Package Microsoft.AspNet.Mvc -Version 3.0.50813.1

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".

The solution was to select "Extensions" under "Assemblies" in the "Add Reference" dialog.

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. I had this problem after installing Glimpse and removing it. System.Web.Mvc was references wrong somehow, cleaning the solution or rebuilding it didin't worked in my case. Just give it try if none of the above answers works for you.

in VS 2017 I cleaned the solution and rebuilt it and that fixed it

Add the reference again from ./packages/Microsoft.AspNet.Mvc.[version]/lib/net45/System.Web.Mvc.dll