Exception Details: System.ArgumentNullException: The value cannot be null. Parameter Name: met at startup

I have a project in which I have API classes, and in this project I created Database.cs. In my MVC project, I updated the API. Uppon application start I get an error message as follows, can anyone help, because I can not understand why I have such an error message.

From http://www.garethelms.org/2011/05/help-getting-started-with-petapoco/#comment-69 , I see that all GetSetMethod () are GetSetMethod (true) since the installation of petaPOCo.

The value cannot be null. Parameter Name: meth Description: An unhandled exception occurred during the execution of the current web request. View the stack trace for more information about the error and where it originated from the code.

Exception Details: System.ArgumentNullException: The 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 code, MethodInfo meth) +9492330 PetaPoco.PocoData.GetFactory (sql string, String connString, Boolean ForceDateTimesToUtc, Int32 firstColumn, Int32 countColumns, IDataTest rdr \ Code \ API \ Models \ PetaPoco.cs: 1992
PetaPoco.d__7 1.MoveNext() in C:\Dev\MyProjectTest\Code\API\Models\PetaPoco.cs:765
System.Collections.Generic.List
1.MoveNext() in C:\Dev\MyProjectTest\Code\API\Models\PetaPoco.cs:765
System.Collections.Generic.List
1.MoveNext() in C:\Dev\MyProjectTest\Code\API\Models\PetaPoco.cs:765
System.Collections.Generic.List
1..ctor (IEnumerable 1 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 []) +51
System.Web.Mvc.ReflectedActionDescriptor.Execute (ControllerContext controllerContext, IDictionary 2 parameters) +409
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary
2 parameters) +409
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary
2 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, Func 1 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.<InvokeActionMethodWithFilters>b__c() +61 System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func
1 continuation) +436
System.Web.Mvc.<>c__DisplayClassf.<InvokeActionMethodWithFilters>b__c() +61 System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func
1 continued) +436
System.Web.Mvc <. > C_DisplayClassf.b_c () +61 System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters (ControllerContext controllerContext, IList 1 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__DisplayClass8 1.<BeginSynchronous>b__7(IAsyncResult _) +42 System.Web.Mvc.Async.WrappedAsyncResult 1.End () +140 System.Web.Mvc.Async.AsyncResultWrapper.End (IAsyncResult asyncR +) 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 (step IExecutionStep, Boolean & completed synchronously) +184

----------------------------------------------- --- ------------------------------ Version Information: Microsoft.NET Framework Version: 4.0.30319; ASP.NET Version: 4.0.30319.272


Customer class

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

`

+4
source share
3 answers

The question was really with POCO, as I skipped the installation and get the identifier

+1
source

Does your poco have a constructor without parameters, i.e. no arguments? He will be needed. If you created your own constructor with parameters, you will not have a constructor without parameters, which can lead to a failure of the reflection code. Maybe this.

+4
source

To make the accepted answer more accurate. I ran into this problem when I had a property in my POCO that matched the column name in the database table, but I didn't have a setting for the property. In my case, it was a property that I myself calculated, so I donโ€™t need the data from the table, and I decided that it was read-only. Adding an empty setter fixed the problem for me.

Probably the best option would be to add the Ignore attribute to this property.

I ended up removing the column from the table.

+3
source

Source: https://habr.com/ru/post/1394339/


All Articles