Reputation: 22136
This problem occurred after upgrading ASP.NET MVC versions.
The type 'System.Web.Mvc.ViewPage' is ambiguous: it could come from assembly...
Upvotes: 10
Views: 8614
Reputation: 131
This solved the thing for me ...
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Abstractions" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Routing" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-4.0.0.1" newVersion="4.0.0.1" />
</dependentAssembly>
</assemblyBinding>
</runtime>
Upvotes: 2
Reputation: 39807
I see that you have provided yourself an answer, but another solution is to update your web.config with a <runtime>
element that redirects dependent assemblies and points to the correct one:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
Note that updating your project from NuGet does the same thing for you automatically for most assemblies.
Upvotes: 12
Reputation: 22136
In solution explorer, click on References > System.Web.Mvc. Click properties and set Copy Local = True.
This way you will be sure to get the correct version of MVC in your project and not rely on whatever version(s) are installed in the GAC. This approach also enables you to bin-deploy the MVC DLL.
Upvotes: 5