0

I have an ASP.NET application targeting .NET 4.0, which uses an ASMX service class for AJAX. One of the methods of that class returns a Tuple<string, string,int>[] to populate one of the controls. This has worked since the beginning (several weeks) with zero issues until today, but after changing a line of code in a totally unrelated method within that service class, the application now yellow-screens with the error System.Tuple`3[System.String,System.String,System.Int32] cannot be serialized because it does not have a parameterless constructor.

The documentation doesn't show a parameterless constructor, and I understand from other answers why one is needed. The question is, with these things being true, how has this ever worked? And, more practically, how do I get it working again, hopefully without re-implementing Tuple?

Jeppe Stig Nielsen
  • 60,409
  • 11
  • 110
  • 181
KeithS
  • 70,210
  • 21
  • 112
  • 164
  • It doesn't need to worry about constructors if it is serialising because that is read only - it's not trying to create objects, just read the contents into an xml string – Callum Linington Apr 04 '17 at 14:41
  • Did you update a library reference? –  Apr 04 '17 at 14:47
  • 1
    There is no way we can answer from the info you provide. You must supply a short code snippet that reproduces the issue. (This can be hard to do without actually solving your own problem in the process. You may answer your own question if this happens.) – Jeppe Stig Nielsen Apr 04 '17 at 14:47
  • Does a `pskill w3wp.exe` followed by `iisreset` and rebuilding the solution help? – shahkalpesh Apr 04 '17 at 14:50
  • This was on IIS Express on my dev machine, so I just stopped the site, then cleaned/rebuilt, and that solved the issue. Would still be interesting to know academically what was wrong and how to fix it besides "turning it off and on again". – KeithS Apr 04 '17 at 14:54

1 Answers1

-1

The Tuple does have the parameterless constructor which is needed by the serializer. You can wrap the tuple and create the default constructor.

Please find the below answer: Why I could not serialize a tuple in C#

Community
  • 1
  • 1
  • As stated in the question, I know that a parameterless constructor is needed. The question is why this code works anyway (until this morning). – KeithS Apr 04 '17 at 16:56