Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 737
Maxim Yefremov Avatar asked Feb 05 '13 14:02

Maxim Yefremov


2 Answers

Just delete System.Web.WebPages from solution references

like image 142
Maxim Yefremov Avatar answered Nov 11 '22 13:11

Maxim Yefremov


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

like image 27
bot Avatar answered Nov 11 '22 14:11

bot