System.MissingMethodException无法创建抽象类。 - 实体框架

时间:2012-01-06 11:28:27

标签: .net asp.net-mvc vb.net asp.net-mvc-3 entity-framework

这些是我的实体:

  Namespace Models.Entity

Public MustInherit Class Client
    <Key()> _
    Public Property ClientID As Integer
    <Required()> _
    Public Property UserName As String
    <Required()> _
    Public Property Password As String

    Public Property OmniSoftKey As String
    <Required()> _
    Public Property isValidated As Boolean
    <Required()> _
    Public Property AddressLine1 As String
    Public Property AddressLine2 As String
    <Required()> _
    Public Property City As String
    <Required()> _
    Public Property TypeOfClient As String
    <Required()> _
    Public Property PostCode As String
    ' <Required()> _
    Public Property ContactPersoon As String
    ' <Required()> _
    Public Property Phone As String
    <Required()> _
    Public Property Email As String
    '<Required()> _
    Public Property BTWNr As String
    Public Property KortingPercentage As Double
    Public Property ConfirmKey As String
    Public Property PrijsCode As Integer

    Public Overridable Property Orders As ICollection(Of Order)


End Class

Public Class SchoolClient
    Inherits Client
    Public Property DefaultClassRoom As String
    Public Property SchoolName As String
End Class
Public Class BusinessClient
    Inherits Client

    Public Property CompanyName As String
End Class

由于我的观点没有运行,我不会表现出来。

我的控制器操作未运行,这是我得到的错误:

System.MissingMethodException: Cannot create an abstract class.
at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache)
at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean skipCheckThis, Boolean fillCache)
at System.Activator.CreateInstance(Type type, Boolean nonPublic)
at System.Web.Mvc.DefaultModelBinder.CreateModel(ControllerContext controllerContext, ModelBindingContext bindingContext, Type modelType)
at System.Web.Mvc.DefaultModelBinder.BindComplexModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
at System.Web.Mvc.DefaultModelBinder.BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
at System.Web.Mvc.ControllerActionInvoker.GetParameterValue(ControllerContext controllerContext, ParameterDescriptor parameterDescriptor)
at System.Web.Mvc.ControllerActionInvoker.GetParameterValues(ControllerContext controllerContext, ActionDescriptor actionDescriptor)
at System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName)
at System.Web.Mvc.Controller.ExecuteCore()
at System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext)
at System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext)
at System.Web.Mvc.MvcHandler.<>c__DisplayClass6.<>c__DisplayClassb.<BeginProcessRequest>b__5()
at System.Web.Mvc.Async.AsyncResultWrapper.<>c__DisplayClass1.<MakeVoidDelegate>b__0()
at System.Web.Mvc.Async.AsyncResultWrapper.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _)
at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`1.End()
at System.Web.Mvc.MvcHandler.<>c__DisplayClasse.<EndProcessRequest>b__d()
at System.Web.Mvc.SecurityUtil.<GetCallInAppTrustThunk>b__0(Action f)
at System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action action)
at System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult)
at System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

这与this question非常相似。

问题是,它以前有用过。我不知道为什么它现在不起作用?可能是什么问题呢?

编辑:

Controller(虽然这个事件没有被解雇)

     Public Function Handle(Optional _Client As Client = Nothing, Optional ByVal OnCheckout As Boolean = False) As ActionResult
        '      Dim x As List(Of Client) = db.Clients.ToList
        ViewBag.CurrentPathDescription = "Inlog / Registreer pagina"
        ViewBag.OnCheckOut = OnCheckout
        Return View("Handle", _Client)
    End Function

0 个答案:

没有答案