Impromptu: Could not load type because it attempts to implement a class as an interface

假如想象 提交于 2020-01-05 08:00:48

问题


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; }
}

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>());

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


回答1:


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; }
}


来源:https://stackoverflow.com/questions/16460370/impromptu-could-not-load-type-because-it-attempts-to-implement-a-class-as-an-in

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!