我有一个项目,其中有我的 API 类,并且在该项目中我生成了 Database.cs。在我的 MVC 项目中,我引用了 API。运行应用程序时,我收到如下错误消息,任何人都可以帮忙,因为我不明白为什么我会收到此错误消息。
从http://www.garethelms.org/2011/05/help-getting-started-with-petapoco/#comment-69,我可以看到自从安装 petaPOCo 以来,所有 GetSetMethod() 都是 GetSetMethod(true) .
值不能为空。参数名称:meth 描述:当前web请求执行过程中发生了未处理的异常。请查看堆栈跟踪以获取有关错误及其源自代码的位置的更多信息。
异常详细信息:System.ArgumentNullException:值不能为空。参数名称:meth
源错误:
第 1990 行:} 第 1991 行:第 1992 行:il.Emit(OpCodes.Callvirt, pc.PropertyInfo.GetSetMethod(true)); // poco Line 1993: Handled = true; 第 1994 行:}
源文件:C:\Dev\MyProjectTest\Code\API\Models\PetaPoco.cs 行:1992
堆栈跟踪:
[ArgumentNullException:值不能为空。参数名称:meth]
System.Reflection.Emit.DynamicILGenerator.Emit(OpCode opcode, MethodInfo meth) +9492330 PetaPoco.PocoData.GetFactory(String sql, String connString, Boolean ForceDateTimesToUtc, Int32 firstColumn, Int32 countColumns, IDataReader r) in C: \Dev\MyProjectTest\Code\API\Models\PetaPoco.cs:1992
PetaPoco.d__7 1..ctor(IEnumerable 1 source) +58 PetaPoco.Database.Fetch(String sql, Object[] args) 在 C:\Dev\ MyProjectTest\Code\API\Models\PetaPoco.cs:601 PecaTest.NewProject.API.Customer.LoadSortedByName() 在 C:\Dev\MyProjectTest\Code\API\Customer.cs:681.MoveNext() in C:\Dev\MyProjectTest\Code\API\Models\PetaPoco.cs:765
System.Collections.Generic.List1 collection) +327 System.Linq.Enumerable.ToList(IEnumerable
PecaTest.NewProject.MvcUI.Models.CustomerListModel..ctor() 在 C:\Dev\MyProjectTest\Code\MvcUI\Models\CustomerListModel.cs:14
PecaTest.NewProject.MvcUI.Controllers.CustomerController.GetIndexView() 在 C:\ Dev\MyProjectTest\Code\MvcUI\Controllers\CustomerController.cs:82
PecaTest.NewProject.MvcUI.Controllers.CustomerController.Index() 在 C:\Dev\MyProjectTest\Code\MvcUI\Controllers\CustomerController.cs:19
lambda_method(Closure , ControllerBase , Object[] ) +96
System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase 控制器, Object[] 参数) +51
System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary 2 参数) +52 System. Web.Mvc.<> c_DisplayClassd.b2 parameters) +409
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary
_a() +127 System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func 1 继续) +436 System.Web.Mvc.<>c_ DisplayClassf.b _c() +61 System.Web.Mvc. ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList 2 参数) +305 System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +830 System.Web.Mvc.Controller.ExecuteCore() +136 System.Web.Mvc. ControllerBase.Execute(RequestContext requestContext) +111 System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +39 System.Web.Mvc.<>c_1 continuation) +436
System.Web.Mvc.<>c__DisplayClassf.<InvokeActionMethodWithFilters>b__c() +61 System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func1 filters, ActionDescriptor actionDescriptor, IDictionary
DisplayClass8.b _4() +65
System.Web.Mvc.Async.<>c_ DisplayClass1.b _0() +44
System.Web.Mvc.Async.<>c__DisplayClass81.<BeginSynchronous>b__7(IAsyncResult _) +42 System.Web.Mvc.Async.WrappedAsyncResult
1.End() +140 System.Web.Mvc .Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +54
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +40
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +52 System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult 结果) +38
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +8969117 System.Web.HttpApplication.ExecuteStep(IExecutionStep 步骤, 布尔值和同步完成)+184-------------------------------------------------- ------------------ 版本信息:Microsoft .NET Framework 版本:4.0.30319;ASP.NET 版本:4.0.30319.272
客户类
` private int id = 0;
public int ID
{
get { return id; }
set { id = ID; }
}
protected string name;
public Customer() { }
public Customer(string name)
{
this.name = name;
}
public string Name
{
get { return name; }
set { name = value; }
}
public override string ToString()
{
return name;
}
`