开发者

Using Razor in Mono

I have been playing around Mono and ASP.NET MVC 3 for a couple of days. It runs Razor almost fine.

When i comment or delete lines where i'm using ViewBag it works fine.

But when i wan开发者_如何学编程t to use ViewBag it gives an exception

Invalid IL code in Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo:Create (Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfoFlags,string): method body is empty.

Description: HTTP 500. Error processing request.

Stack Trace:

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>  

Stack trace is pointing out 13th line which is below:

ViewBag.Message = "Welcome to ASP.NET MVC!";  

Am i missing any assembly reference maybe?

Can you help me please?

Thank you in advance.


ViewBag is implemented as a dynamic and requires .NET 4.0. Is it possible you are not running your site under .NET 4.0?


I am not sure why my post was deleted. I just wanted to say that I used ViewBag with mono and it worked - this can be quite important as the question can be understood as 'Does Razor works with Mono?' or - more importantly - 'Does it work with ViewBag too?'. I was also asking about versions of mono and xsp, because I had some issues which were fixed by upgrading to freshly compiled git version. To OP: please provide such information, maybe I will be able to help more.


ViewBag works great foe me using Razor on Mono 2.10 running under Linux. Make sure you host it using eg. xsp4 (instead xsp2) which supports .Net/Clr 4 and therefore dynamics.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜