Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The type 'System.Web.Mvc.ViewPage' is ambiguous

Tags:

asp.net-mvc

This problem occurred after upgrading ASP.NET MVC versions.

The type 'System.Web.Mvc.ViewPage' is ambiguous: it could come from assembly...

like image 911
mike nelson Avatar asked Jul 14 '13 01:07

mike nelson


3 Answers

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.

like image 159
Tommy Avatar answered Nov 15 '22 07:11

Tommy


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.

like image 43
mike nelson Avatar answered Nov 15 '22 06:11

mike nelson


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>
like image 2
Eric Gontier Avatar answered Nov 15 '22 08:11

Eric Gontier