Maxim Yefremov
Maxim Yefremov

Reputation: 14175

The type 'ModelClientValidationRule' exists in both dlls

I downloaded source code of example written in asp.net mvc3 visual studio 2010

Open solution file by visual studio 2012. It coverts source code to 2012 and opens solution.

When I build solution got error:

Error 1 The type 'System.Web.Mvc.ModelClientValidationRule' exists in both 'c:\Program Files (x86)\Microsoft ASP.NET\ASP.NET MVC 3\Assemblies\System.Web.Mvc.dll' and 'c:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v2.0\Assemblies\System.Web.WebPages.dll' C:\studyCode\MVCDemo-Part12\MVCDemo-Part12\MVCDemo\Attributes\Validation\EqualAttribute.cs 54 28 MVCDemo

Upvotes: 15

Views: 14324

Answers (4)

Danimal111
Danimal111

Reputation: 2062

http://www.asp.net/whitepapers/mvc4-release-notes

See this link with known errors when upgrading from MVC 3 to MVC 4:

Follow the steps and you should be up and running in minutes.

FYI - If you downloaded a zip file from the web, right click on the file(s), click Properties and select "Unblock" prior to unzipping or you will have pain.

I added Notes -- the rest is from the site referenced above with known errors when upgrading from MVC3 to 4:

*** Automatic Upgrade *** Upgrading an ASP.NET MVC 3 Project to ASP.NET MVC 4 ASP.NET MVC 4 can be installed side by side with ASP.NET MVC 3 on the same computer, which gives you flexibility in choosing when to upgrade an ASP.NET MVC 3 application to ASP.NET MVC 4.

The simplest way to upgrade is to create a new ASP.NET MVC 4 project and copy all the views, controllers, code, and content files from the existing MVC 3 project to the new project and then to update the assembly references in the new project to match any non-MVC template included assembiles you are using. If you have made changes to the Web.config file in the MVC 3 project, you must also merge those changes into the Web.config file in the MVC 4 project.

*** MANUAL Upgrade ****** To manually upgrade an existing ASP.NET MVC 3 application to version 4, do the following:

In all Web.config files in the project (there is one in the root of the project, one in the Views folder, and one in the Views folder for each area in your project), replace every instance of the following text (note: System.Web.WebPages, Version=1.0.0.0 is not found in projects created with Visual Studio 2012): System.Web.Mvc, Version=3.0.0.0 System.Web.WebPages, Version=1.0.0.0 System.Web.Helpers, Version=1.0.0.0 System.Web.WebPages.Razor, Version=1.0.0.0

with the following corresponding text:

System.Web.Mvc, Version=4.0.0.0
System.Web.WebPages, Version=2.0.0.0
System.Web.Helpers, Version=2.0.0.0
System.Web.WebPages.Razor, Version=2.0.0.0

NOTE - "webpages:Version" wasn't in my settings at all... I added only the "PreserveLoginUrl" line*

In the root Web.config file, update the webPages:Version element to "2.0.0.0" and add a new PreserveLoginUrl key that has the value "true":

In Solution Explorer, right-click on the References and select Manage NuGet Packages. In the left pane, select Online\NuGet official package source, then update the following: ASP.NET MVC 4 (Optional) jQuery, jQuery Validation and jQuery UI (Optional) Entity Framework (Optonal) Modernizr

This is as far as I had to go to get it my version to work.... **

In Solution Explorer, right-click the project name and then select Unload Project. Then right-click the name again and select Edit ProjectName.csproj. Locate the ProjectTypeGuids element and replace {E53F8FEA-EAE0-44A6-8774-FFD645390401} with {E3E379DF-F4C6-4180-9B81-6769533ABE47}. Save the changes, close the project (.csproj) file you were editing, right-click the project, and then select Reload Project. If the project references any third-party libraries that are compiled using previous versions of ASP.NET MVC, open the root Web.config file and add the following three bindingRedirect elements under the configuration section:

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

Happy Coding

Dan B.

Upvotes: 0

Tony
Tony

Reputation: 1

Right click on the project name in VS2010. click "Add Deployable Dependencies". Rebuild

Upvotes: 0

bot
bot

Reputation: 4921

This answers may also solve your problem:

  1. In the root Web.config file, add a new entry with the key webPages:Version and the value 1.0.0.0.

    <appSettings>
    <add key="webpages:Version" value="1.0.0.0"/>
    <add key="webpages:Version" value="1.0.0.0"/>
    <add key="ClientValidationEnabled" value="true"/>
    <add key="UnobtrusiveJavaScriptEnabled" value="true"/>
    </appSettings>
    

2.In Solution Explorer, right-click the project name and then select Unload Project. Then right-click the name again and select Edit ProjectName.csproj.

3.Locate the following assembly references:

    <Reference Include="System.Web.WebPages"/>
    <Reference Include="System.Web.Helpers" />

Replace them with the following:

<Reference Include="System.Web.WebPages, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL "/>
<Reference Include="System.Web.Helpers, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL "/>

4.Save the changes, close the project (.csproj) file you were editing, and then right-click the project and select Reload.

REFERENCE: http://forums.asp.net/t/1723108.aspx/1

also try: http://www.asp.net/learn/whitepapers/mvc4-release-notes#_Toc303253815

OR YOU MAY ALSO TRY THIS

Edit:

ProjectName.csproj

Change

<Reference Include="System.Web.WebPages"/> 

To

<Reference Include="System.Web.WebPages, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL "/><br/><br/>

note: POSSIBLE DUPLICATE OF THIS QUESTION

Upvotes: 5

Maxim Yefremov
Maxim Yefremov

Reputation: 14175

Just delete System.Web.WebPages from solution references

Upvotes: 42

Related Questions