Bug 39389 - hu-HU as CurrentCulture causes InvalidOperationException in ASP.NET MVC View renderer
Summary: hu-HU as CurrentCulture causes InvalidOperationException in ASP.NET MVC View ...
Status: RESOLVED FIXED
Alias: None
Product: Class Libraries
Classification: Mono
Component: mscorlib ()
Version: 4.2.0 (C6)
Hardware: All All
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2016-03-05 12:19 UTC by nzsb
Modified: 2016-03-09 16:20 UTC (History)
3 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
demo mvc site (9.91 KB, application/x-zip-compressed)
2016-03-05 12:19 UTC, nzsb
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description nzsb 2016-03-05 12:19:39 UTC
Created attachment 15276 [details]
demo mvc site

- create a ASP.NET MVC 4.5.2 application with Visual Studio 2015 without application insights (deleted the codedom nodes from web.config to make it work with mono)
- set the CurrentCulture to hu-HU before View rendering, e.g. in global.asax:
        protected void Application_BeginRequest()
        {
            Thread.CurrentThread.CurrentCulture = new CultureInfo("hu-HU");
        }
- when I run my site with xsp4 and try to access the view, I get the following exception:
System.InvalidOperationException
The view found at '~/Views/Home/About.cshtml' was not created.

Description: HTTP 500.Error processing request.
Details: Non-web exception. Exception origin (name of application or object): System.Web.Mvc.
Exception stack trace:
  at System.Web.Mvc.BuildManagerCompiledView.Render (System.Web.Mvc.ViewContext viewContext, System.IO.TextWriter writer) <0xa613d78 + 0x0010f> in <filename unknown>:0 
  at System.Web.Mvc.ViewResultBase.ExecuteResult (System.Web.Mvc.ControllerContext context) <0xa60bdb8 + 0x00187> in <filename unknown>:0 
  at System.Web.Mvc.ControllerActionInvoker.InvokeActionResult (System.Web.Mvc.ControllerContext controllerContext, System.Web.Mvc.ActionResult actionResult) <0xa60bd98 + 0x00017> in <filename unknown>:0 
  at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive (IList`1 filters, Int32 filterIndex, System.Web.Mvc.ResultExecutingContext preContext, System.Web.Mvc.ControllerContext controllerContext, System.Web.Mvc.ActionResult actionResult) <0xa60ba20 + 0x00052> in <filename unknown>:0 
  at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive (IList`1 filters, Int32 filterIndex, System.Web.Mvc.ResultExecutingContext preContext, System.Web.Mvc.ControllerContext controllerContext, System.Web.Mvc.ActionResult actionResult) <0xa60ba20 + 0x0016f> in <filename unknown>:0 


You can also use the attached project, it contains only the neccessary stuff.

Tried on Windows with mono 4.2.1 and Raspbian with mono 4.2.2.
It works fine with .NET. Settings the current culture also works in other application types (console, Web Forms etc.)

I tried some other cultures, with those I do not get an exception.
Comment 1 nzsb 2016-03-05 12:30:35 UTC
Tried on Windows with mono 4.2.2, issue persists.
Comment 2 Marek Safar 2016-03-05 14:28:10 UTC
I cannot reproduce the issue on Mac. Could you find out the source (stack trace) of the original issue IOE seems to be only cover of

https://github.com/mono/aspnetwebstack/blob/master/src/System.Web.Mvc/BuildManagerCompiledView.cs#L73
Comment 3 nzsb 2016-03-06 18:38:06 UTC
You are correct, I tried to get a stack trace with Xamarin Studio. Before the IOE I did not get any other exception in the request.
I configured to debug the Mono libraries, downloaded the sources and copied to the exact path where it was located in compile time (as of mdb). I could see the source of mscorlib and System.Web for instance with debugger, but for System.Web.Mvc3 I always got a disassembled code, where I could not put any breakpoints or step into/over or watch any variable like in Visual Studio which I normally use. If you could provide me additional info on how to debug this particular assembly with Mono or what could be my debugging problem, I would be happy to analyze the issue further.

I could reproduce the same exception on Ubuntu with Mono 4.2.2 as well with Xamarin Studio, just by creating a new ASP.NET MVC Razor project and setting the current culture in the controller:
Thread.CurrentThread.CurrentCulture = new CultureInfo("hu-HU");
It is very easy to reproduce.

I do not have an OSX, so I cannot try it there.
Comment 4 Marek Safar 2016-03-07 20:23:53 UTC
That still works for me.

Could you try to run it with Mono 4.4 preview ?

http://www.mono-project.com/download/alpha/
Comment 5 nzsb 2016-03-09 16:20:43 UTC
I tried with Mono 4.4 Alpha 1 (4.3.2.467) on Ubuntu and the issue seems to be fixed in this version. On Windows I could not try because XSP crashed with my project.
I will wait for the next stable release and try that in my production environment, thank you for your help!