gpt4 book ai didi

petapoco - 异常详细信息 : System. ArgumentNullException : Value cannot be null. 参数名称:运行时的 meth

转载 作者:行者123 更新时间:2023-12-04 01:32:01 25 4
gpt4 key购买 nike

我有一个项目,其中包含我的 API 类,并且在该项目中我生成了 Database.cs。在我的 MVC 项目中,我已经引用了 API。运行应用程序后,我收到如下错误消息,任何人都可以帮忙,因为我不明白为什么我会收到此错误消息。

来自 http://www.garethelms.org/2011/05/help-getting-started-with-petapoco/#comment-69 ,我可以看到自从安装了 petaPOCo 以来,所有的 GetSetMethod() 都是 GetSetMethod(true)。

Value cannot be null. Parameter name: meth Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ArgumentNullException: Value cannot be null. Parameter name: meth

Source Error:

Line 1990: } Line 1991: Line 1992: il.Emit(OpCodes.Callvirt, pc.PropertyInfo.GetSetMethod(true)); // poco Line 1993: Handled = true; Line 1994: }

Source File: C:\Dev\MyProjectTest\Code\API\Models\PetaPoco.cs Line: 1992

Stack Trace:

[ArgumentNullException: Value cannot be null. Parameter name: 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__71.MoveNext() in
C:\Dev\MyProjectTest\Code\API\Models\PetaPoco.cs:765

System.Collections.Generic.List
1..ctor(IEnumerable1 collection) +327
System.Linq.Enumerable.ToList(IEnumerable
1 source) +58
PetaPoco.Database.Fetch(String sql, Object[] args) in C:\Dev\MyProjectTest\Code\API\Models\PetaPoco.cs:601
PecaTest.NewProject.API.Customer.LoadSortedByName() in C:\Dev\MyProjectTest\Code\API\Customer.cs:68
PecaTest.NewProject.MvcUI.Models.CustomerListModel..ctor() in C:\Dev\MyProjectTest\Code\MvcUI\Models\CustomerListModel.cs:14
PecaTest.NewProject.MvcUI.Controllers.CustomerController.GetIndexView() in C:\Dev\MyProjectTest\Code\MvcUI\Controllers\CustomerController.cs:82
PecaTest.NewProject.MvcUI.Controllers.CustomerController.Index() in C:\Dev\MyProjectTest\Code\MvcUI\Controllers\CustomerController.cs:19
lambda_method(Closure , ControllerBase , Object[] ) +96
System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) +51
System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary2 parameters) +409

System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext
controllerContext, ActionDescriptor actionDescriptor, IDictionary
2 parameters) +52
System.Web.Mvc.<>c_DisplayClassd.b_a() +127 System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func1 continuation) +436

System.Web.Mvc.<>c__DisplayClassf.<InvokeActionMethodWithFilters>b__c()
+61 System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter
filter, ActionExecutingContext preContext, Func
1 continuation) +436
System.Web.Mvc.<>c_DisplayClassf.b_c() +61 System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList1 filters, ActionDescriptor actionDescriptor,
IDictionary
2 parameters) +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_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 result) +38
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +8969117 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +184

-------------------------------------------------------------------------------- Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version: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;
}

`

最佳答案

为了使接受的答案更精确一点。当我的 POCO 中有一个属性与数据库表中的列名匹配时,我遇到了这个问题,但我没有该属性的 setter。就我而言,这是我自己计算的一个属性,所以我并不真正需要表中的数据,我打算将其设为只读。添加一个空的 setter 为我解决了这个问题。

一个可能更好的选择是将 Ignore 属性添加到该属性。

我最终从表格中删除了该列。

关于petapoco - 异常详细信息 : System. ArgumentNullException : Value cannot be null. 参数名称:运行时的 meth,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9107799/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com