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

StackOverflow https://stackoverflow.com/questions/16460370

  •  19-04-2022
  •  | 
  •  

문제

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

도움이 되었습니까?

해결책

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 ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top