MonoとASP.NET MVC 3を数日間使っています。それは剃刀をほとんどうまく動かす。
ViewBagを使用している行をコメントや削除するとうまくいきます。
しかし、私はViewBagを使用する場合には例外にMicrosoft.CSharp.RuntimeBinder.CSharpArgumentInfoでMonoでRazorを使用する
無効なILコードを提供します:(Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfoFlags、文字列)を作成します。メソッドの本体は空です。
説明:HTTP 500。処理要求のエラーです。
スタックトレース:
System.InvalidProgramException: Invalid IL code in Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo:Create (Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfoFlags,string): method body is empty.
NerdDinnerV3.Controllers.HomeController.Index() [0x0000a] in /home/telebovich/Projects/EmptyMvc2Application/EmptyMvc2Application/Controllers/HomeController.cs:13 at (wrapper dynamic-method) object.lambda_method (System.Runtime.CompilerServices.Closure,System.Web.Mvc.ControllerBase,object[]) <IL 0x00006, 0x0002f>
at System.Web.Mvc.ActionMethodDispatcher.Execute (System.Web.Mvc.ControllerBase,object[]) <IL 0x00008, 0x0001b>
at System.Web.Mvc.ReflectedActionDescriptor.Execute (System.Web.Mvc.ControllerContext,System.Collections.Generic.IDictionary`2<string, object>) <IL 0x00072, 0x00103>
at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod (System.Web.Mvc.ControllerContext,System.Web.Mvc.ActionDescriptor,System.Collections.Generic.IDictionary`2<string, object>) <IL 0x00003, 0x00019>
at System.Web.Mvc.ControllerActionInvoker/<>c__DisplayClass15.<InvokeActionMethodWithFilters>b__12() <IL 0x0002d, 0x00068>
at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter (System.Web.Mvc.IActionFilter,System.Web.Mvc.ActionExecutingContext,System.Func`1<System.Web.Mvc.ActionExecutedContext>) <IL 0x00031, 0x000b6>
スタックトレースは以下の通りです13行を指摘している:
ViewBag.Message = "Welcome to ASP.NET MVC!";
私は多分すべてのアセンブリ参照が不足しているだろうか?
私を助けてもらえますか?
ありがとうございます。
この回答を見る:http://stackoverflow.com/questions/4239645/does-the-razor-view-engine-work-for-monoまた、ViewData/ViewBagの代わりにビューモデルを使用することをお勧めします。 –