I'm trying to send a Json Object to a MVC 4 controller.
When doing this I get a HTTP 500 Error caused by the following exceptions :
A first chance exception of type 'System.FormatException' occurred in mscorlib.dll
A first chance exception of type 'System.FormatException' occurred in System.dll
A first chance exception of type 'System.InvalidOperationException' occurred in System.Web.Mvc.dll
A first chance exception of type 'System.MissingMethodException' occurred in mscorlib.dll
A first chance exception of type 'System.MissingMethodException' occurred in System.Web.Mvc.dll
A first chance exception of type 'System.MissingMethodException' occurred in System.Web.Mvc.dll
A first chance exception of type 'System.MissingMethodException' occurred in System.Web.Mvc.dll
A first chance exception of type 'System.MissingMethodException' occurred in System.Web.Mvc.dll
A first chance exception of type 'System.MissingMethodException' occurred in System.Web.dll
To debug this I created a C# object based on my Json with json2csharp.com It works perfectly this way.
When I compare my original object with the debug one created, they are perfectly similar but the original one is defined with many empty classes with few
[XmlInclude(typeof(AClassContainingTheSameFieldAsMyDebugOne))]
on top of them. The referenced AClassContainingTheSameFieldAsMyDebugOne
contains the exact fields that I should have found in the empty class.
The only solution I found I to keep my debug class and create a method to convert it to the original class. It works, but it's messy and very hard/dangerous to maintain. I took great care of checking if the both class had the same fields name and they do.
Therefore I have the following questions :
- Is it possible
XmlInclude
is responsible of this or am I wrong ? - Is there a better way to solve the problem than what I did ?
- If previous answers are : Yes then No : Is there an (easy) way to check if two object represent strictly the same entity or do I have to make "fuzzing test" ?
No comments:
Post a Comment