Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
122 views
in Technique[技术] by (71.8m points)

c# - 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.

The problem is that the reference to System.Web.Mvc.dll is broken.

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.

Path is C:Program FilesMicrosoft ASP.NETASP.NET MVC 3AssembliesSystem.Web.Mvc.dll Version is 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. If I remove it, and try to add it back using VS2010's Add Reference dialog, it doesn't show.

Wandering around the web has led me to suggestions involving updating MVC using NuGet. We didn't use NuGet, in our VS2010 projects, so that doesn't seem quite right, for this situation. I tried it anyway, and ended up with half-a-dozen missing references.

When I look at the properties for "C:Program FilesMicrosoft ASP.NETASP.NET MVC 3AssembliesSystem.Web.Mvc.dll" in Windows Explorer, on the build machine I see version 3.0.0.0.

When I look at the properties on the dev machine, I see version 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.

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 MVC3Assemblies" folder, into a folder in my project. 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:

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

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...