Bug 669786 - Can't use JavaScriptSerializer
Summary: Can't use JavaScriptSerializer
Status: RESOLVED DUPLICATE of bug 664813
Alias: None
Product: Mono: Class Libraries
Classification: Mono
Component: Sys.Web (show other bugs)
Version: 2.10.x
Hardware: x86 Mac OS X 10.6
: P5 - None : Normal
Target Milestone: ---
Assignee: Marek Habersack
QA Contact: Mono Bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-02-05 21:43 UTC by Abe Gillespie
Modified: 2011-03-16 21:39 UTC (History)
1 user (show)

See Also:
Found By: ---
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments
MVC project (10.39 KB, application/zip)
2011-02-22 03:05 UTC, Abe Gillespie
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Abe Gillespie 2011-02-05 21:43:38 UTC
If you try to use Ajax.BeginForm(), client-side validation (<% Html.EnableClientValidation(); %>), or anything else that uses the JavaScriptSerializer type you get the following exception. This works find in 2.8.x

[System.TypeInitializationException]: An exception was thrown by the type initializer for System.Web.Script.Serialization.JavaScriptSerializer
  at System.Web.Mvc.JsonResult.ExecuteResult (System.Web.Mvc.ControllerContext context) [0x000a2] in /private/tmp/monobuild/build/BUILD/mono-2.10/mcs/class/System.Web.Mvc2/System.Web.Mvc/JsonResult.cs:67 
  at System.Web.Mvc.ControllerActionInvoker.InvokeActionResult (System.Web.Mvc.ControllerContext controllerContext, System.Web.Mvc.ActionResult actionResult) [0x00000] in /private/tmp/monobuild/build/BUILD/mono-2.10/mcs/class/System.Web.Mvc2/System.Web.Mvc/ControllerActionInvoker.cs:243 
  at System.Web.Mvc.ControllerActionInvoker+<InvokeActionResultWithFilters>c__AnonStorey38.<>m__47 () [0x00000] in /private/tmp/monobuild/build/BUILD/mono-2.10/mcs/class/System.Web.Mvc2/System.Web.Mvc/ControllerActionInvoker.cs:281 
  at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter (IResultFilter filter, System.Web.Mvc.ResultExecutingContext preContext, System.Func`1 continuation) [0x00025] in /private/tmp/monobuild/build/BUILD/mono-2.10/mcs/class/System.Web.Mvc2/System.Web.Mvc/ControllerActionInvoker.cs:255 
[System.InvalidCastException]: Cannot cast from source type to destination type.
  at System.Web.Script.Serialization.JavaScriptSerializer..ctor (System.Web.Script.Serialization.JavaScriptTypeResolver resolver, Boolean registerConverters) [0x0000d] in /private/tmp/monobuild/build/BUILD/mono-2.10/mcs/class/System.Web.Extensions/System.Web.Script.Serialization/JavaScriptSerializer.cs:66 
  at System.Web.Script.Serialization.JavaScriptSerializer..cctor () [0x00000] in <filename unknown>:0
Comment 1 Marek Habersack 2011-02-21 18:30:08 UTC
Please provide a small, self-contained and ready to run test case which demonstrates the issue. After attaching it to the report, please reopen the bug.
Comment 2 Abe Gillespie 2011-02-22 03:05:23 UTC
Created attachment 415385 [details]
MVC project
Comment 3 Abe Gillespie 2011-02-22 03:06:21 UTC
Sorry, I missed that you actually have to submit the Json form before seeing this error.  Please see the attached project.
Comment 4 Abe Gillespie 2011-02-26 19:04:04 UTC
The attachment doesn't compile because I missed renaming the namespace in Global.asax - set it to ExerciseJson and it will run fine.  This has not been fixed in 2.10.1.
Comment 5 Marek Habersack 2011-03-16 21:39:03 UTC
This is a duplicate of bug #664813 - please see https://bugzilla.novell.com/show_bug.cgi?id=664813#c1 for explanation and a workaround

*** This bug has been marked as a duplicate of bug 664813 ***