[英]Impromptu: Could not load type because it attempts to implement a class as an interface
I have just started using Impromptu after a recommendation from someone on stack. 经过栈上某人的推荐后,我才刚刚开始使用Impromptu。
I believe I have implemented it correctly but I am getting the error "Could not load type because it attempts to implement a class as an interface" 我相信我已经正确实现了它,但是却收到错误“由于试图将类实现为接口而无法加载类型”
In my portable class library I have the following model: 在我的可移植类库中,我具有以下模型:
public class Route
{
public User user { get; set; }
}
public class User
{
public Name name { get; set; }
}
public class Name
{
public string title { get; set; }
public string firstName { get; set; }
public string middleName { get; set; }
public string lastName { get; set; }
}
and I have created the following IClasses in my MVC project: 并且在我的MVC项目中创建了以下IClass:
public class IRoute
{
public IUser user { get; set; }
}
public class IUser
{
public IName name { get; set; }
}
public class IName
{
[Required]
public string firstName { get; set; }
[Required]
public string lastName { get; set; }
}
and in my controller I have the following being sent to the view: 在控制器中,我将以下内容发送到视图:
Route sendthis = new Route();
return View(sendthis.ActLike<IRoute>());
but I get the error "Could not load type because it attempts to implement a class as an interface" 但出现错误“由于试图将类实现为接口而无法加载类型”
I cannot work out what I have done wrong. 我无法弄清楚我做错了什么。 Can anyone help please? 有人可以帮忙吗?
Thanks 谢谢
I hadn't changed the local classes to "Interface". 我没有将本地类更改为“接口”。
public interface IRoute
{
IUser user { get; set; }
}
public interface IUser
{
IName name { get; set; }
}
public interface IName
{
[Required]
string firstName { get; set; }
[Required]
string lastName { get; set; }
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.