Impromptu:无法加载类型,因为它尝试将类实现为接口 [英] 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.
我相信我已经正确地实现它,但是我得到的错误无法加载类型因为它试图实现一个类为接口
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; }
}
和我在我的MVC项目创建了以下IClasses:
and I have created the following IClasses in my MVC project:
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>());
但我得到错误Could not load type because it attempt to implement a class as an interface
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?
感谢
推荐答案
将本地类更改为接口。
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; }
}
这篇关于Impromptu:无法加载类型,因为它尝试将类实现为接口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!