API クラスを含むプロジェクトがあり、そのプロジェクトで Database.cs を生成しました。私の MVC プロジェクトでは、API を参照しました。アプリケーションを実行すると、次のようなエラー メッセージが表示されます。なぜこのエラー メッセージが表示されるのか理解できないので、誰か助けてください。
http://www.garethelms.org/2011/05/help-getting-started-with-petapoco/#comment-69から、petaPOCo がインストールされて以来、すべての GetSetMethod() が GetSetMethod(true) であることがわかります.
値を null にすることはできません。パラメーター名: meth 説明: 現在の Web 要求の実行中に未処理の例外が発生しました。エラーの詳細とコード内のどこでエラーが発生したかについては、スタック トレースを確認してください。
例外の詳細: System.ArgumentNullException: 値を null にすることはできません。パラメータ名:メタ
ソース エラー:
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: 値を null にすることはできません。パラメータ名: 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) in C:\Dev\ MyProjectTest\Code\API\Models\PetaPoco.cs:601 PecaTest.NewProject.API.Customer.LoadSortedByName() in 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() 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 コントローラー、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 フィルター、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、文字列 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 タグ) +54
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult、Object タグ) +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 ステップ) , Boolean& completedSynchronously) +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;
}
`