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

1k views Asked by At

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

There are 1 answers

0
Trevor Daniel On BEST ANSWER

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