Error 2 Inconsistent accessibility: property type 'eData.DataClases.Masters.HttpPostedFileBase' is less accessible than property 'Data.KdbContext.ProfileImage' C:\Users\Mad\Videos\Projects2015\eData\DataClases\Masters\MasterContext.cs 117 32 eData
模型
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using eData.DataClases.Masters;
namespace eData
{
public class RegisterModel
{
[Required]
[Display(Name = "User name")]
public string UserName { get; set; }
[Required]
[StringLength(100, ErrorMessage = "The {0} must be at least {2} characters long.", MinimumLength = 6)]
[DataType(DataType.Password)]
[Display(Name = "Password")]
public string Password { get; set; }
[DataType(DataType.Password)]
[Display(Name = "Confirm password")]
[Compare("Password", ErrorMessage = "The password and confirmation password do not match.")]
public string ConfirmPassword { get; set; }
public HttpPostedFileBase ProfileImage { get; set; }
}
}
答案 0 :(得分:2)
某处您定义了自定义HttpPostedFileBase
类。大概是这样的:
namespace eData.DataClases.Masters
{
private class HttpPostedFileBase
{
// implementation
}
}
(或者internal
代替private
)
由于您的HttpPostedFileBase
类具有更严格的可见性(private
或internal
),因此您无法将其用作public
属性的类型:
public HttpPostedFileBase ProfileImage { get; set; }
这是因为遇到该属性的任何消费代码都无法知道该属性的类型。
通常,修复方法是使类的可见性与属性匹配,或使属性的可见性与类匹配。 (制作课程public
或相应地设置属性private
或internal
。)但是,老实说,您甚至有HttpPostedFileBase
的自定义实现这一事实是首先有点奇怪......