System.ComponentModel.DataAnnotations.compare vs System.Web.Mvc.Compare

前端 未结 6 1984
星月不相逢
星月不相逢 2020-12-24 04:44

MVC 4 Beta project fails to compile after upgrading to .Net 4.5.

This happens due to conflict between System.ComponentModel.DataAnnotations.CompareAttribute

6条回答
  •  难免孤独
    2020-12-24 05:34

    On this post, they also suggest another solution, which is to move the reference of the preferred namespace for Compare() inside the model's namespace. Eg. if you prefer to use Compare from System.Web.Mvc, use:

    using System.ComponentModel.DataAnnotations;
    
    namespace MyProject.MyViewModel
    {
        using System.Web.Mvc;
    

    The compiler will search inside the model's namespace first.

提交回复
热议问题